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

Clean yaml validator false positive output #682

Merged
merged 3 commits into from
Jun 28, 2024

Conversation

abaskk-msft
Copy link
Contributor

Problem

  • In the current validation output there is an edge case with returning output on an Invalid Schema.
  • The schema structure requires that at the root of the yaml we either have a single control or an array of controls (using a OneOf json-schema statement)
    image
  • In a valid schema, a single evaluation path being true (object or array of objects) will make the entire schema true
  • In an invalid schema, both evaluation paths will be false. Suppose we wanted to trace an error; we would have to go down both evaluation paths in the evaluation tree (one of which would always evaluate to false even if the schema was valid).
  • This additional useless information is output on the console to the user and is confusing/uninformative. This pr removes the evaluation path which contains useless information.

Solution

  • Among the schema evaluation path which require we have a single control object or array of control object; we find which evaluation path has the longest suffix and filter out the rest of the evaluation paths with a smaller length suffix.

Validation

  • Only local test with examples I made. Perhaps we can add unit tests on the actual errors of the schema, as opposed to simply checking if the entire schema evaluated true or false

@abaskk-msft abaskk-msft removed the request for review from mizrael June 26, 2024 19:03
src/YamlValidator/ValidatorResults.cs Outdated Show resolved Hide resolved
@abaskk-msft abaskk-msft merged commit 96f0efa into master Jun 28, 2024
4 checks passed
@abaskk-msft abaskk-msft deleted the users/t-abaskar/yaml-validator-clean-errors branch June 28, 2024 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants