Skip to content

fix: display errors when schema validation fails#4623

Draft
chronicc wants to merge 1 commit intoansible:mainfrom
chronicc:fix-schema-validate-errors-display
Draft

fix: display errors when schema validation fails#4623
chronicc wants to merge 1 commit intoansible:mainfrom
chronicc:fix-schema-validate-errors-display

Conversation

@chronicc
Copy link
Copy Markdown

@chronicc chronicc commented Mar 22, 2026

When using the ansible native configuration I get a "Failed to validate" error without further notice about what is wrong.

extensions/molecule/config.yml

---
ansible:
  executor:
    args:
      ansible_playbook:
        - --inventory=${MOLECULE_SCENARIO_DIRECTORY}/../inventory/hosts.yml
    env:
      ANSIBLE_COLLECTIONS_PATHS: ${MOLECULE_SCENARIO_DIRECTORY}/../../..
      ANSIBLE_FORCE_COLOR: true
      ANSIBLE_HOST_KEY_CHECKING: false

scenario:
  test_sequence:
    - prepare
    - converge
    - verify
    - idempotence
    - verify
    - cleanup

shared_state: true

extensions/molecule/default/molecule.yml

---
scenario:
  test_sequence:
    - create
    - destroy

Shell Output

❯ uv run molecule create
INFO     Found config file /home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/config.yml
INFO     Collection 'chronicc.toolchain' detected.
INFO     Scenarios will be used from 'extensions/molecule'
WARNING  default ➜ config: The scenario config file ('/home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/default/molecule.yml') has been modified since the scenario was created. If recent changes are important, reset the scenario with 'molecule destroy' to clean up created items or 'molecule reset' to clear current configuration.
ERROR    Failed to validate /home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/default/molecule.yml


Environment

# Python
❯ uv run python -V
Python 3.13.7

# Python Dependencies
❯ uv pip freeze
ansible-builder==3.1.1
ansible-compat==25.12.1
ansible-core==2.19.7
ansible-creator==26.3.2
ansible-dev-environment==26.2.0
ansible-dev-tools==26.3.1
ansible-lint==26.3.0
ansible-navigator==26.1.3
ansible-runner==2.4.3
ansible-sign==0.1.5
attrs==26.1.0
bindep==2.14.0
black==26.3.1
bracex==2.6
cachetools==7.0.5
cffi==2.0.0
click==8.3.1
colorama==0.4.6
cryptography==46.0.5
distlib==0.4.0
distro==1.9.0
enrich==1.2.7
execnet==2.1.2
filelock==3.25.2
iniconfig==2.3.0
jinja2==3.1.6
jmespath==1.1.0
jsonschema==4.26.0
jsonschema-specifications==2025.9.1
lockfile==0.12.2
markdown-it-py==4.0.0
markupsafe==3.0.3
mdurl==0.1.2
molecule==26.3.0
mypy-extensions==1.1.0
onigurumacffi==1.5.0
packaging==26.0
parsley==1.3
pathspec==1.0.4
pbr==7.0.3
pexpect==4.9.0
platformdirs==4.9.4
pluggy==1.6.0
ptyprocess==0.7.0
pycparser==3.0
pygments==2.19.2
pyproject-api==1.10.0
pytest==9.0.2
pytest-ansible==26.2.0
pytest-xdist==3.8.0
python-daemon==3.1.2
python-discovery==1.2.0
python-gnupg==0.5.6
pytokens==0.4.1
pyyaml==6.0.3
referencing==0.37.0
resolvelib==1.2.1
rich==14.3.3
rpds-py==0.30.0
ruamel-yaml==0.19.1
ruamel-yaml-clib==0.2.15
ruff==0.15.7
setuptools==82.0.1
subprocess-tee==0.4.2
tomli-w==1.2.0
tox==4.50.3
tox-ansible==26.3.0
typing-extensions==4.15.0
tzdata==2025.3
virtualenv==21.2.0
wcmatch==10.1
yamllint==1.38.0

After fix

❯ uv run molecule create
INFO     Found config file /home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/config.yml
INFO     Collection 'chronicc.toolchain' detected.
INFO     Scenarios will be used from 'extensions/molecule'
WARNING  default ➜ config: The scenario config file ('/home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/default/molecule.yml') has been modified since the scenario was created. If recent changes are important, reset the scenario with 'molecule destroy' to clean up created items or 'molecule reset' to clear current configuration.
ERROR    Failed to validate /home/chronicc/git/chronicc/ansible-collection-toolchain/extensions/molecule/default/molecule.yml

Additional properties are not allowed ('env' was unexpected)

@chronicc chronicc force-pushed the fix-schema-validate-errors-display branch from 2bf1718 to 88e00e4 Compare March 22, 2026 08:43
@github-actions github-actions bot added fix and removed fix labels Mar 22, 2026
@chronicc
Copy link
Copy Markdown
Author

Apparently the code uses a list to handle errors but the tests did not reflect that. Hence I updated the tests also.

@ssbarnea ssbarnea marked this pull request as draft April 1, 2026 12:32
@ssbarnea
Copy link
Copy Markdown
Member

ssbarnea commented Apr 1, 2026

@chronicc Please sign the commit, we cannot merge PRs without it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

2 participants