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

opa check: only check schema types when user provides schemas #7124

Merged

Conversation

tjons
Copy link
Contributor

@tjons tjons commented Oct 16, 2024

Why the changes in this PR are needed?

v0.69.0 caused a regression in opa check where a file that referenced non-provided schemas now fails validation. This PR fixes the regression and restores the behavior from v0.68.0.

What are the changes in this PR?

Resolves #7116 by only adding the useTypeCheckAnnotations option if the user has provided a path to schemas to validate.

This regression was introduced in 76f7038. In that commit, the signature of the processAnnotations method changed: 76f7038#diff-d23ff3bfce1aa610d34183f8ccab5ecfd112e19dd9ebca55d69f231a29b62337R227. The annotation's path will nearly always exist, causing the checker to attempt to validate it and error because its schema is not found.

An alternate approach would be to return early if the type of the annotation is nil, similar to how the path was handled in v0.68.0.

Notes to assist PR review:

Further comments:

@tjons
Copy link
Contributor Author

tjons commented Oct 16, 2024

this needs further iteration - the test suite informed me that inline schemas should always be validated. Will fix.

@anderseknert
Copy link
Member

@tjons — yeah, I imagine this may turn out to be a can of worms, lol

An alternate approach would be to return early if the type of the annotation is nil, similar to how the path was handled in v0.68.0.

👍

@johanfylling may have some ideas too

@tjons tjons force-pushed the tjons/7116-schemas-annotations branch 2 times, most recently from afb58c8 to a100455 Compare October 16, 2024 13:55
Signed-off-by: Tyler Schade <[email protected]>

only check schemas when schemas are provided

Signed-off-by: Tyler Schade <[email protected]>
@tjons tjons force-pushed the tjons/7116-schemas-annotations branch from a100455 to 16cdb08 Compare October 18, 2024 11:00
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@anderseknert anderseknert merged commit 555fe84 into open-policy-agent:main Oct 18, 2024
28 checks passed
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.

schemas annotation issue in v0.69.0
2 participants