ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
814 stars 1.49k forks source link

keycloak client_id parse error #7508

Open RandJV opened 10 months ago

RandJV commented 10 months ago

Summary

I use the community.general.keycloak_client module to create clients in keycloak. I came across a bug that if the client_id parameter in the url value contains text containing letters and numbers, the module cannot parse it correctly and throws an error. If the text contains only letters or only numbers, the module will work correctly, but if they are used together, then an error

Issue Type

Bug Report

Component Name

keycloak_client.py

Ansible Version

$ ansible --version
ansible [core 2.13.3]
  config file = /home/user/.ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/venv/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/venv/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
# /home/user/.ansible/collections/ansible_collections
Collection        Version
----------------- -------
community.general 8.0.1

# /home/user/venv/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 5.5.0

Configuration

$ ansible-config dump --only-changed
ANSIBLE_NOCOWS(/home/user/.ansible.cfg) = True
DEFAULT_HOST_LIST(/home/user/.ansible.cfg) = ['/home/user/ansible/inventories/hosts.yml']
DEFAULT_REMOTE_USER(/home/user/.ansible.cfg) = user
DEFAULT_VAULT_PASSWORD_FILE(/home/user/.ansible.cfg) = /home/user/.vault_pass
DIFF_ALWAYS(/home/user/.ansible.cfg) = True
DIFF_CONTEXT(/home/user/.ansible.cfg) = 5
HOST_KEY_CHECKING(/home/user/.ansible.cfg) = False
RETRY_FILES_ENABLED(/home/user/.ansible.cfg) = False

OS / Environment

Debian GNU/Linux 11 (bullseye)

Steps to Reproduce

- client_id: https://example.com/test/bpf42cckgjkim7l1pq16
  realm: test
  secret: "secret"
  protocol: saml

Expected Results

A client is created in keycloak.

Actual Results

The full traceback is:
Traceback (most recent call last):
  File "/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py", line 107, in <module>
    _ansiballz_main()
  File "/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py", line 99, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py", line 47, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.keycloak_client', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.keycloak_client', _modlib_path=modlib_path),
  File "/usr/lib/python3.9/runpy.py", line 210, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py", line 990, in <module>
  File "/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py", line 947, in main
  File "/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py", line 770, in sanitize_cr
TypeError: list indices must be integers or slices, not str
"module_stderr": "Traceback (most recent call last):\n  File \"/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py\", line 107, in <module>\n    _ansiballz_main()\n  File \"/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py\", line 99, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/user/.ansible/tmp/ansible-tmp-1699672075.8295214-1818076-54658927213471/AnsiballZ_keycloak_client.py\", line 47, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.keycloak_client', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.keycloak_client', _modlib_path=modlib_path),\n  File \"/usr/lib/python3.9/runpy.py\", line 210, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.9/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.9/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py\", line 990, in <module>\n  File \"/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py\", line 947, in main\n  File \"/tmp/ansible_community.general.keycloak_client_payload__rvajepp/ansible_community.general.keycloak_client_payload.zip/ansible_collections/community/general/plugins/modules/keycloak_client.py\", line 770, in sanitize_cr\nTypeError: list indices must be integers or slices, not str\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1

Code of Conduct

ansibullbot commented 10 months ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 10 months ago

cc @eikef @mattock @ndclt click here for bot help

ansibullbot commented 1 month ago

cc @thomasbach-dev click here for bot help