Skip to content

fix: display errors when schema validation fails - #4623

Merged
shvenkat-rh merged 2 commits into
ansible:mainfrom
chronicc:fix-schema-validate-errors-display
Sep 17, 2026
Merged

shvenkat-rh merged 2 commits into
ansible:mainfrom
chronicc:fix-schema-validate-errors-display

Conversation

@chronicc

@chronicc chronicc commented Mar 22, 2026 •

Copy link
Copy Markdown
Contributor

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)

Summary by CodeRabbit

  • Bug Fixes

    • Improved validation error messages by displaying each issue on a separate line for easier reading.
    • Validation failures are now formatted more clearly when multiple issues are reported, making it easier to identify and resolve individual problems.
  • Tests

    • Updated validation coverage to reflect the improved handling and presentation of multiple validation errors.

@chronicc
chronicc requested a review from a team as a code owner March 22, 2026 07:57
@github-actions github-actions Bot added the fix label Mar 22, 2026
@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 8180ab2 to e968014 Compare March 22, 2026 08:01
@github-actions github-actions Bot added fix and removed fix labels Mar 22, 2026
@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from e968014 to 2bf1718 Compare March 22, 2026 08:23
@github-actions github-actions Bot added fix and removed fix labels Mar 22, 2026
@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
Contributor 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 previously approved these changes Apr 1, 2026
@ssbarnea
ssbarnea marked this pull request as draft April 1, 2026 12:32
@ssbarnea

ssbarnea commented Apr 1, 2026

Copy link
Copy Markdown
Member

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

@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 88e00e4 to 2f823e2 Compare April 1, 2026 19:58
@github-actions github-actions Bot added fix and removed fix labels Apr 1, 2026
@chronicc

chronicc commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

@ssbarnea Signed :)

@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 2f823e2 to 304f31c Compare April 2, 2026 19:14
@github-actions github-actions Bot added fix and removed fix labels Apr 2, 2026
@chronicc
chronicc marked this pull request as ready for review April 2, 2026 19:15
@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 304f31c to 9b75f0b Compare April 2, 2026 19:34
@github-actions github-actions Bot added fix and removed fix labels Apr 2, 2026
@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 9b75f0b to 0f94550 Compare April 12, 2026 09:31
shatakshiiii
shatakshiiii previously approved these changes Jun 4, 2026
@shatakshiiii

shatakshiiii commented Jun 4, 2026 •

Copy link
Copy Markdown
Contributor

Hi @chronicc , some of the tests are failing please take a look

moving this to draft until CI is back to green.

@shatakshiiii
shatakshiiii marked this pull request as draft June 4, 2026 09:16
@shvenkat-rh

Copy link
Copy Markdown
Contributor

@chronicc any updates on this draft?

@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 27bacfc to 6a3d301 Compare September 15, 2026 15:25
@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: b8dbfc40-f89a-4b7a-8432-b3c7f15cf444

📥 Commits

Reviewing files that changed from the base of the PR and between 500f645 and 0ad369b.

📒 Files selected for processing (2)
  • src/molecule/config.py
  • tests/unit/test_config.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The validation failure message now displays each error on a separate line. The related unit test now supplies validation errors as a list.

Changes

Validation Error Formatting

Layer / File(s) Summary
Format validation errors
src/molecule/config.py, tests/unit/test_config.py
Config._validate joins validation errors with newline separators. The unit test mocks the validator with a list of errors.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: cidrblock

Merge Risk: ⚪ Minimal · up to 0ad36

The PR improves schema validation messages without introducing a supported current-head risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix to display schema validation errors.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@chronicc
chronicc force-pushed the fix-schema-validate-errors-display branch from 6a3d301 to 500f645 Compare September 15, 2026 15:38
@chronicc
chronicc marked this pull request as ready for review September 16, 2026 08:16
@shvenkat-rh
shvenkat-rh merged commit ec36b52 into ansible:main Sep 17, 2026
20 checks passed
@chronicc
chronicc deleted the fix-schema-validate-errors-display branch September 19, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants