From 581ad7bbd8c6577f381c41da4996d49d1d229da0 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 09:11:43 +0200 Subject: [PATCH] [PR #8762/b79ac4f0 backport][stable-8] keycloak_user_federation: fix key error when removing mappers in update (#8780) keycloak_user_federation: fix key error when removing mappers in update (#8762) * remove new mappers without an id from list comprehension * add changelog fragment * Update changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein (cherry picked from commit b79ac4f0ac3225da70fa52d2c6df2734457813e4) Co-authored-by: fgruenbauer --- ...762-keycloac_user_federation-fix-key-error-when-updating.yml | 2 ++ plugins/modules/keycloak_user_federation.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml diff --git a/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml b/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml new file mode 100644 index 0000000000..08da8ae21a --- /dev/null +++ b/changelogs/fragments/8762-keycloac_user_federation-fix-key-error-when-updating.yml @@ -0,0 +1,2 @@ +bugfixes: + - keycloak_user_federation - fix key error when removing mappers during an update and new mappers are specified in the module args (https://github.com/ansible-collections/community.general/pull/8762). \ No newline at end of file diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 00f407ec03..e327d4ac20 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -1004,7 +1004,7 @@ def main(): for before_mapper in before_comp.get('mappers', []): # remove unwanted existing mappers that will not be updated - if not before_mapper['id'] in [x['id'] for x in desired_mappers]: + if not before_mapper['id'] in [x['id'] for x in desired_mappers if 'id' in x]: kc.delete_component(before_mapper['id'], realm) for mapper in desired_mappers: