Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARNING Ignored exception from RoleNames .../meta/main.yml (meta): string indices must be integers, not 'str' #4000

Closed
nodiscc opened this issue Jan 28, 2024 · 5 comments · Fixed by #4054
Assignees
Labels

Comments

@nodiscc
Copy link

nodiscc commented Jan 28, 2024

Summary

After upgrading from ansible-lint 6.21.1 to 6.22.2, warnings about ignored exceptions started appearing in ansible-lint output

WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rocketchat/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/nfs_server/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/awesome_selfhosted_html/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rss2email/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rss_bridge/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/planarally/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/icecast/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/docker/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/k8s/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/valheim_server/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/proxmox/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/znc/meta/main.yml (meta): string indices must be integers, not 'str'
Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 6.22.2 using ansible-core:2.16.2 ansible-compat:4.1.11 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
  • ansible installation method: pip
  • ansible-lint installation method: pip
  • OS: Debian 12
STEPS TO REPRODUCE
git clone https://gitlab.com/nodiscc/toolbox/
cd toolbox.git/ARCHIVE/ANSIBLE-COLLECTION
make test-ansible-lint  # or ansible-lint -v -x fqcn[action-core],fqcn[action],name[casing],yaml[truthy],schema[meta],yaml[line-length],var-naming[no-role-prefix] roles/rocketchat
Desired Behavior

No warnings about ignored exceptions should appear.

Actual Behavior
git clone https://gitlab.com/nodiscc/toolbox/
cd toolbox.git/ARCHIVE/ANSIBLE-COLLECTION
make test-ansible-lint # or ansible-lint -v -x fqcn[action-core],fqcn[action],name[casing],yaml[truthy],schema[meta],yaml[line-length],var-naming[no-role-prefix] roles/rocketchat
...
INFO     Executing syntax check on role roles/homepage_extra_icons (0.98s)
INFO     Executing syntax check on role roles/vscodium (0.98s)
INFO     Executing syntax check on role roles/reverse_ssh_tunnel (1.03s)
INFO     Executing syntax check on role roles/nfs_server (1.03s)
INFO     Executing syntax check on role roles/proxmox (1.07s)
INFO     Executing syntax check on role roles/pulseaudio (1.08s)
INFO     Executing syntax check on role roles/rss2email (1.09s)
INFO     Executing syntax check on role roles/valheim_server (1.11s)
INFO     Executing syntax check on role roles/planarally (1.13s)
INFO     Executing syntax check on role roles/znc (1.13s)
INFO     Executing syntax check on role roles/rss_bridge (1.14s)
INFO     Executing syntax check on role roles/k8s (1.18s)
INFO     Executing syntax check on role roles/rocketchat (0.69s)
INFO     Executing syntax check on role roles/mariadb (0.71s)
INFO     Executing syntax check on role roles/docker (0.68s)
INFO     Executing syntax check on role roles/awesome_selfhosted_html (0.69s)
INFO     Executing syntax check on role roles/icecast (0.91s)
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rocketchat/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/docker/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rss2email/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/icecast/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/znc/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/rss_bridge/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/planarally/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/awesome_selfhosted_html/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/nfs_server/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/k8s/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/valheim_server/meta/main.yml (meta): string indices must be integers, not 'str'
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/proxmox/meta/main.yml (meta): string indices must be integers, not 'str'

Passed: 0 failure(s), 0 warning(s) on 248 files. Last profile that met the validation criteria was 'production'.


@ssbarnea
Copy link
Member

Please create a MINIMAL git repository to reproduce this error message, no extra stuff, build scripts or so, ideally just a single YML file. In some cases you might need to add few more.

@nodiscc
Copy link
Author

nodiscc commented Feb 1, 2024

Hi @ssbarnea,

here is a minimal test case:

git clone https://github.com/nodiscc/minimal-test-ansible-lint-4000
cd minimal-test-ansible-lint-4000/
python3 -m venv .venv && source .venv/bin/activate && pip3 install ansible-lint
ansible-lint roles/test_role/
$ ansible-lint roles/test_role/
WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/test_role/meta/main.yml (meta): 'dependencies'

Passed: 0 failure(s), 0 warning(s) on 3 files. Last profile that met the validation criteria was 'production'.

@audgirka audgirka removed the new Triage required label Feb 5, 2024
@audgirka audgirka moved this from Roadmap to In Progress in 🧰 devtools project board Feb 5, 2024
@audgirka
Copy link
Contributor

audgirka commented Feb 5, 2024

@nodiscc @ssbarnea This is fixed as part of #3993
Will be available in the next release.

@audgirka audgirka closed this as completed Feb 5, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in 🧰 devtools project board Feb 5, 2024
@nodiscc
Copy link
Author

nodiscc commented Feb 5, 2024

Thanks @ajinkyau
Small bug but I appreciate the very quick fix.

@corubba
Copy link
Contributor

corubba commented Feb 14, 2024

I don't think this is fixed yet. dependencies does not have to be a list of dicts, it can also be a simple list of strings.

dependencies:
  - some_other_role
  - and_one_more_role

In that case, trying to access it as a dict still results in this error.

WARNING  Ignored exception from RoleNames.<bound method RoleNames.matchyaml of role-name: Role name {0} does not match ``^*$`` pattern.> while processing roles/testrole/meta/main.yml (meta): string indices must be integers, not 'str'
DEBUG    Ignored exception details
Traceback (most recent call last):
  File "/home/corubba/.venv/lib/python3.11/site-packages/ansiblelint/_internal/rules.py", line 94, in getmatches
    matches.extend(method(file))
                   ^^^^^^^^^^^^
  File "/home/corubba/.venv/lib/python3.11/site-packages/ansiblelint/rules/role_name.py", line 100, in matchyaml
    role_name = role["role"]
                ~~~~^^^^^^^^
TypeError: string indices must be integers, not 'str'

nodiscc added a commit to nodiscc/xsrv that referenced this issue Feb 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants