From a977c6f7c16fbe84fe19c54cd80e7bc4ea3f1e47 Mon Sep 17 00:00:00 2001 From: Guillaume Dorschner <44686652+GuillaumeDorschner@users.noreply.github.com> Date: Mon, 8 Dec 2025 22:51:02 +0100 Subject: [PATCH] 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 Co-authored-by: Felix Fontein --------- 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 2e96d09265..e31b3e7248 100644 --- a/plugins/modules/keycloak_realm.py +++ b/plugins/modules/keycloak_realm.py @@ -846,6 +846,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"] = "********"