Set field descriptor on map entry violations#324
Open
haines wants to merge 1 commit into
Open
Conversation
Signed-off-by: Andrew Haines <andrew@haines.org.nz>
haines
added a commit
to cerbos/cerbos
that referenced
this pull request
Jun 16, 2026
This PR removes `util.ReadJSONOrYAML` in favour of our custom parser, so that we get consistent behaviour and richer errors everywhere. This means we can remove the workaround of validating test files with the JSON schema in favour of protovalidate. I did run into one drawback of protovalidate, which is that it reports errors based on the numeric enum values (bufbuild/protovalidate-go#125). I've added custom handling for `enum.in` validation failures (which are the only enum-based rules we have) to construct a friendlier error message. Unfortunately, I then ran into bugs in protovalidate (bufbuild/protovalidate-go#322, bufbuild/protovalidate-go#323), so I've had to fork it and add a `replace` directive until my PR (bufbuild/protovalidate-go#324) is merged. We'll need to copy that to Hub. I've done all the internal YAML/JSON parsing (mainly test cases) with the custom parser too, which is probably not strictly necessary, but did help to surface several bugs in the parser, so I think it's worthwhile. Signed-off-by: Andrew Haines <haines@cerbos.dev>
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.
Fixes #322