1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-03-22 05:09:12 +00:00

keycloak_user_rolemapping: handle None response for client role lookup (#11471)

* fix(keycloak_user_rolemapping): handle None response for client role lookup

When adding a client role to a user who has no existing roles for that
client, get_client_user_rolemapping_by_id() returns None. The existing
code indexed directly into the result causing a TypeError. Add the same
None check that already existed for realm roles since PR #11256.

Fixes #10960

* fix(tests): use dict format for task vars in keycloak_user_rolemapping tests

Task-level vars requires a YAML mapping, not a sequence. The leading
dash (- roles:) produced a list instead of a dict, which ansible-core
2.20 rejects with "Vars in a Task must be specified as a dictionary".

* Update changelogs/fragments/keycloak-user-rolemapping-client-none-check.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Ivan Kokalovic 2026-02-18 20:24:35 +01:00 committed by GitHub
parent 80d21f2a0d
commit 34938ca1ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 73 additions and 11 deletions

View file

@ -0,0 +1,5 @@
bugfixes:
- keycloak_user_rolemapping - fix ``TypeError`` crash when adding a client
role to a user who has no existing roles for that client
(https://github.com/ansible-collections/community.general/issues/10960,
https://github.com/ansible-collections/community.general/pull/11471).