Better error messages for schema validation #16097
Open
+188
−18
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.
Description
This adds more informative error messages for some common schema validation errors.
This detects capitalization errors and small edit distance errors in attribute names and adjusts the error messages accordingly. If there is no close match to an attribute name, then the valid attribute names at that node in the schema are listed
Examples:
{"Name": "project"...
->project is missing a 'name' attribute, found 'Name' instead
..."rutnime": "test"...
->project is missing a 'runtime' attribute, found 'rutnime'. instead
..."template": {"displayNameDisplayName": "foo"...
->'displayNameDisplayName' not allowed, the expected attributes are 'config', 'description', 'displayName', 'important', 'metadata' and 'quickstart'
Fixes # (issue)
Checklist
make tidy
to update any new dependenciesmake lint
to verify my code passes the lint checkgofumpt
make changelog
and committed thechangelog/pending/<file>
documenting my change