Skip to content

keycloak_authentication: TypeError when flow has no authenticationExecutions #11547

@koke1997

Description

@koke1997

Summary

keycloak_authentication crashes with TypeError: 'NoneType' object is not iterable when a flow is defined without authenticationExecutions.

COMPONENT NAME

keycloak_authentication

ANSIBLE VERSION
ansible [core 2.18.x]
community.general 12.5.0

Steps to reproduce

Define a Keycloak authentication flow task without any executions:

- name: "Create empty flow"
  community.general.keycloak_authentication:
    auth_keycloak_url: https://keycloak.example.com
    auth_realm: master
    auth_username: admin
    auth_password: secret
    realm: my-realm
    alias: "My empty flow"
    providerId: basic-flow
    state: present
    # authenticationExecutions intentionally omitted

Expected behavior

The flow is created/updated with no executions — no error.

Actual behavior

Could not create or update executions for authentication flow My empty flow in realm my-realm: 'NoneType' object is not iterable

Root cause

In create_or_update_executions() at line 276:

if "authenticationExecutions" in config:
    for new_exec_index, new_exec in enumerate(config["authenticationExecutions"], start=0):

When authenticationExecutions is not provided in the task, module.params.get("authenticationExecutions") returns None, and line 413 stores that None in the config dict:

"authenticationExecutions": module.params.get("authenticationExecutions"),

The key therefore exists in the dict ("in" check passes), but its value is None, so enumerate(None) raises TypeError.

Fix

if "authenticationExecutions" in config and config["authenticationExecutions"] is not None:

Fix is available in PR: #11548

Environment

  • community.general version: 12.5.0
  • Keycloak version: 26.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bughas_prmodulemodule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions