When attempting to use validation with a JSON Schema, if any document in the schema contains a $ref tag inside a allOf, opa eval ... will print a cryptic error (looking like a GO dump).
The $ref tag is used in JSON Schemas as a basic form of inheritance, including the contents of the referenced schema in the current one. It may be useful to use this together with allOf for multiple inheritance.
Short description
When attempting to use validation with a JSON Schema, if any document in the schema contains a
$ref
tag inside aallOf
,opa eval ...
will print a cryptic error (looking like a GO dump).The
$ref
tag is used in JSON Schemas as a basic form of inheritance, including the contents of the referenced schema in the current one. It may be useful to use this together withallOf
for multiple inheritance.Steps To Reproduce
Copy the json bellow to
schema.json
;Create a basic Rego policy (what it does is not relevant, but the file needs to be a valid policy) named
policy.rego
;Create an empty file
input.json
;Run
opa eval 'input' policy.rego -i input.json -s schema.json
;The output will be
Expected behavior
This is a valid JSON Schema (see https://www.jsonschemavalidator.net/s/a6r4YT0v) and OPA should use it to verify the Rego code.
Additional context
Slack conversation: https://openpolicyagent.slack.com/archives/CBR63TK2A/p1704984957314319