From fc5de1a194ebca97431ca2a85b617a919ae2bb87 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 10 Mar 2026 06:57:51 +0100 Subject: [PATCH] [PR #11548/2f33ff10 backport][stable-12] keycloak_authentication: fix TypeError when flow has no authenticationExecutions (#11565) keycloak_authentication: fix TypeError when flow has no authenticationExecutions (#11548) * TIAAS-12174: fix(keycloak_authentication): handle None authenticationExecutions When a flow is defined without authenticationExecutions, module.params.get() returns None but the key still exists in the config dict. The 'in' check passes but iterating over None raises TypeError. Guard the iteration with an explicit None check. * keycloak_authentication: add changelog fragment for NoneType fix * keycloak_authentication: update changelog fragment with PR link * Update plugins/modules/keycloak_authentication.py * Changelog polishing --------- (cherry picked from commit 2f33ff1041825c80cc52073645b05d25feb34200) Co-authored-by: Ivan Kokalovic <67540157+koke1997@users.noreply.github.com> Co-authored-by: Ivan Kokalovic Co-authored-by: Felix Fontein --- .../fragments/keycloak-authentication-none-executions.yml | 5 +++++ plugins/modules/keycloak_authentication.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/keycloak-authentication-none-executions.yml diff --git a/changelogs/fragments/keycloak-authentication-none-executions.yml b/changelogs/fragments/keycloak-authentication-none-executions.yml new file mode 100644 index 0000000000..ca089346fc --- /dev/null +++ b/changelogs/fragments/keycloak-authentication-none-executions.yml @@ -0,0 +1,5 @@ +bugfixes: + - keycloak_authentication - fix ``TypeError`` crash when a flow is defined without + ``authenticationExecutions`` + (https://github.com/ansible-collections/community.general/issues/11547, + https://github.com/ansible-collections/community.general/pull/11548). diff --git a/plugins/modules/keycloak_authentication.py b/plugins/modules/keycloak_authentication.py index 1678f46f85..0c4fba36d5 100644 --- a/plugins/modules/keycloak_authentication.py +++ b/plugins/modules/keycloak_authentication.py @@ -273,7 +273,7 @@ def create_or_update_executions(kc, config, realm="master"): after = "" before = "" execution = None - if "authenticationExecutions" in config: + if config.get("authenticationExecutions") is not None: # Get existing executions on the Keycloak server for this alias existing_executions = kc.get_executions_representation(config, realm=realm) for new_exec_index, new_exec in enumerate(config["authenticationExecutions"], start=0):