Conversation
Member
|
@wak327 please sign the cla |
Author
When no subschema of an anyOf matches, the anyOf validator reports best_match() of the collected errors followed by a generic "... is not valid under any of the given schemas" error. For anyOf clauses made of alternative required keys, such as the one for yum_repos, best_match() just picks the first alternative, so a repo without any URL reported that 'baseurl' is required and never mentioned metalink or mirrorlist. When every subschema fails only because it lacks one required property, report all of those properties in a single error instead: yum_repos.epel-testing: 'baseurl', 'metalink' or 'mirrorlist' is a required property Other anyOf failures are reported as before. Fixes canonicalGH-5502
wak327
force-pushed
the
fix/schema-anyof-required-message
branch
from
September 30, 2026 20:10
3421043 to
6c76d59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Commit Message
Additional Context
Fixes #5502
Output of
cloud-init schema -c yum.yamlfor the config in the Test Steps below.Before:
After:
chpasswd.usersbenefits as well. A user entry with onlynamenow reportschpasswd.users.0: 'type' or 'password' is a required property. Previously it reported only'type'plus the generic error.The combined message is used only when every anyOf subschema fails with a single
requirederror on the object itself. All other failures still go throughbest_match()as before. This includes a subschema that lacks two properties, type or enum errors, and the networkanyOf_type_*handling. The missing property comes from the error'svalidator_valuerather than from parsing the message, so this works the same on jsonschema 3.2.0 (lowest supported) and on current releases.Verified with the pinned black, isort, ruff, pylint and mypy. The full unit suite passes with current jsonschema (5,783 tests) and with jsonschema 3.2.0 (5,779 tests).
Test Steps
Merge type