From bc61b2d656040661e2abedfc2a25793fe05de1d1 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 23:03:21 +0100 Subject: [PATCH] [PR #11260/a977c6f7 backport][stable-11] fix(sanitize_cr): avoid crash when realmrep is empty (#11267) fix(sanitize_cr): avoid crash when realmrep is empty (#11260) * fix(docs): missing info on id when creating realms * fix(sanitize_cr): avoid crash when realmrep is empty * remove unrelated change * remove unrelated change * added changlog * correct: changelogs * Update changelogs --------- (cherry picked from commit a977c6f7c16fbe84fe19c54cd80e7bc4ea3f1e47) Co-authored-by: Guillaume Dorschner <44686652+GuillaumeDorschner@users.noreply.github.com> Co-authored-by: Guillaume Dorschner Co-authored-by: Felix Fontein --- .../fragments/11260-keycloak-realm-crash-when-no-realms.yml | 3 +++ plugins/modules/keycloak_realm.py | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/11260-keycloak-realm-crash-when-no-realms.yml diff --git a/changelogs/fragments/11260-keycloak-realm-crash-when-no-realms.yml b/changelogs/fragments/11260-keycloak-realm-crash-when-no-realms.yml new file mode 100644 index 0000000000..f972fea17b --- /dev/null +++ b/changelogs/fragments/11260-keycloak-realm-crash-when-no-realms.yml @@ -0,0 +1,3 @@ +--- +bugfixes: + - keycloak_realm - fixed crash in ``sanitize_cr()`` when ``realmrep`` was ``None`` (https://github.com/ansible-collections/community.general/pull/11260). diff --git a/plugins/modules/keycloak_realm.py b/plugins/modules/keycloak_realm.py index bcb6cd62d8..b13f40ea0f 100644 --- a/plugins/modules/keycloak_realm.py +++ b/plugins/modules/keycloak_realm.py @@ -829,6 +829,9 @@ def sanitize_cr(realmrep): :param realmrep: the realmrep dict to be sanitized :return: sanitized realmrep dict """ + if not realmrep: + return realmrep + result = realmrep.copy() if 'secret' in result: result['secret'] = '********'