Skip to content

Commit

Permalink
fix(keycloak_client): avoid TypeError if attributes is a list
Browse files Browse the repository at this point in the history
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
  • Loading branch information
thomasbach-dev committed May 23, 2024
1 parent 4792e21 commit 7e641d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- keycloak_client - fix TypeError in sanitize_cr function. The function expected a dict where in some cases a list might occur (https://github.com/ansible-collections/community.general/pull/8403).
5 changes: 3 additions & 2 deletions plugins/modules/keycloak_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,8 +775,9 @@ def sanitize_cr(clientrep):
if 'secret' in result:
result['secret'] = 'no_log'
if 'attributes' in result:
if 'saml.signing.private.key' in result['attributes']:
result['attributes']['saml.signing.private.key'] = 'no_log'
attributes = result['attributes']
if isinstance(attributes, dict) and 'saml.signing.private.key' in attributes:
attributes['saml.signing.private.key'] = 'no_log'
return normalise_cr(result)


Expand Down

0 comments on commit 7e641d5

Please sign in to comment.