From 6777d9471f3d0b88d52b563c06dbbf87c491512b Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:17:12 +0000 Subject: [PATCH] [PR #8831/2ae41fa8 backport][stable-8] keycloak_user_federation: get the before mappers from `before_comp` to fix `UnboundLocalError` (#8849) keycloak_user_federation: get the before mappers from `before_comp` to fix `UnboundLocalError` (#8831) * fix: get the before mappers from `before_comp` * add changelog fragment * Adjust changelog fragment. --------- Co-authored-by: Felix Fontein (cherry picked from commit 2ae41fa83f44aefce38cd845e377dcdd73b9f32b) Co-authored-by: fgruenbauer --- .../fragments/8831-fix-error-when-mapper-id-is-provided.yml | 2 ++ plugins/modules/keycloak_user_federation.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8831-fix-error-when-mapper-id-is-provided.yml diff --git a/changelogs/fragments/8831-fix-error-when-mapper-id-is-provided.yml b/changelogs/fragments/8831-fix-error-when-mapper-id-is-provided.yml new file mode 100644 index 0000000000..63ac352057 --- /dev/null +++ b/changelogs/fragments/8831-fix-error-when-mapper-id-is-provided.yml @@ -0,0 +1,2 @@ +bugfixes: + - keycloak_user_federation - fix the ``UnboundLocalError`` that occurs when an ID is provided for a user federation mapper (https://github.com/ansible-collections/community.general/pull/8831). \ No newline at end of file diff --git a/plugins/modules/keycloak_user_federation.py b/plugins/modules/keycloak_user_federation.py index 6e04d1b116..4107f4dc76 100644 --- a/plugins/modules/keycloak_user_federation.py +++ b/plugins/modules/keycloak_user_federation.py @@ -892,7 +892,7 @@ def main(): if cid is None: old_mapper = {} elif change.get('id') is not None: - old_mapper = next((before_mapper for before_mapper in before_mapper.get('mappers', []) if before_mapper["id"] == change['id']), None) + old_mapper = next((before_mapper for before_mapper in before_comp.get('mappers', []) if before_mapper["id"] == change['id']), None) if old_mapper is None: old_mapper = {} else: