Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #8403/572caeaa backport][stable-9] keycloak_client: avoid TypeError if result["attributes"] is a list #8427

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented May 26, 2024

This is a backport of PR #8403 as merged into main (572caea).

SUMMARY

This fixes a TypeError in the keycloak_client module.

Longer description:

As sanitize_cr might be executed after normalise_cr, result['attributes'] can be of type list and we run into:

TypeError: list indices must be integers or slices, not str

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

keycloak_client

ADDITIONAL INFORMATION

Full stack trace (keycloak_client.py got renamed to mdz_keycloak_client.py):

Traceback (most recent call last):
  File "/root/.ansible/tmp/ansible-tmp-1716369175.8611605-165495-177683398669149/AnsiballZ_mdz_keycloak_client.py", line 107, in <module>
    _ansiballz_main()
  File "/root/.ansible/tmp/ansible-tmp-1716369175.8611605-165495-177683398669149/AnsiballZ_mdz_keycloak_client.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/root/.ansible/tmp/ansible-tmp-1716369175.8611605-165495-177683398669149/AnsiballZ_mdz_keycloak_client.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible.modules.mdz_keycloak_client', init_globals=dict(_module_fqn='ansible.modules.mdz_keycloak_client', _modlib_path=modlib_path),
  File "/usr/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_mdz_keycloak_client_payload_uw8ct1px/ansible_mdz_keycloak_client_payload.zip/ansible/modules/mdz_keycloak_client.py", line 999, in <module>
  File "/tmp/ansible_mdz_keycloak_client_payload_uw8ct1px/ansible_mdz_keycloak_client_payload.zip/ansible/modules/mdz_keycloak_client.py", line 956, in main
  File "/tmp/ansible_mdz_keycloak_client_payload_uw8ct1px/ansible_mdz_keycloak_client_payload.zip/ansible/modules/mdz_keycloak_client.py", line 779, in sanitize_cr
TypeError: list indices must be integers or slices, not str

…8403)

* fix(keycloak_client): avoid TypeError if attributes is a list

As sanitize_cr might be executed after normalise_cr, result['attributes'] can be of type list and we
run into:

TypeError: list indices must be integers or slices, not str

* Update changelog fragment.

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 572caea)
@felixfontein felixfontein merged commit 5a36e84 into stable-9 May 26, 2024
131 checks passed
@felixfontein felixfontein deleted the patchback/backports/stable-9/572caeaa39ad3efd6083afafba9fd4fe4c88f9fd/pr-8403 branch May 26, 2024 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants