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

ansible-lint type checks don't account for jinja2 expressions that change data type #4043

Closed
Drugoy opened this issue Feb 21, 2024 · 1 comment · Fixed by #4117
Closed

ansible-lint type checks don't account for jinja2 expressions that change data type #4043

Drugoy opened this issue Feb 21, 2024 · 1 comment · Fixed by #4117
Labels

Comments

@Drugoy
Copy link

Drugoy commented Feb 21, 2024

Summary

ansible-lint type checks don't account for jinja2 expressions that change data type

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 24.2.0 using ansible-core:2.15.5 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE

Create a role with the following files:

defaults/main.yml
---
mydict:
  a: a
  b: b


meta/argument_specs.yml
---
argument_specs:
  main:
    options:
      myvar:
        type: str
        required: true
        choices: "{{ mydict.keys() | list }}"
Desired Behavior

ansible-lint should understand that jinja2 expression that is used in choices actually yields an array

Actual Behavior

schema[role-arg-spec]: $.argument_specs.main.options.myvar.choices '{{ mydict.keys() | list }}' is not of type 'array'.

@Drugoy Drugoy added bug new Triage required labels Feb 21, 2024
@ssbarnea ssbarnea removed the new Triage required label Feb 28, 2024
@ssbarnea
Copy link
Member

That seems like another schema error, as the schema should allow jinja templates for this field too. Please make a PR to fix it.

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.

2 participants