Skip to content

Support arrays as input for json.match_schema#8264

Merged
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
sspaink:fixjsonschema
Jan 29, 2026
Merged

Support arrays as input for json.match_schema#8264
anderseknert merged 1 commit intoopen-policy-agent:mainfrom
sspaink:fixjsonschema

Conversation

@sspaink
Copy link
Copy Markdown
Member

@sspaink sspaink commented Jan 28, 2026

resolve: #6615

Running the provided examples with the --show-builtin-errors flag I got the error: 1 error occurred: array_input/array_input.rego:10: eval_builtin_error: json.match_schema: wrong type, expected string or object

Seems like a simple fix to process arrays the same way as objects, testing with this change led to the expected output:

❯ ./opa_darwin_arm64 eval -b . -f pretty data.array_input.policy --input array_input/input/valid/data.json
{
  "errors": [],
  "matches": true
}
❯ ./opa_darwin_arm64 eval -b . -f pretty data.array_input.policy --input array_input/input/invalid_type/data.json
{
  "errors": [
    {
      "desc": "foo is required",
      "error": "0: foo is required",
      "field": "0",
      "type": "required"
    }
  ],
  "matches": false
}

@netlify
Copy link
Copy Markdown

netlify bot commented Jan 28, 2026

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 4c8c88d
🔍 Latest deploy log https://app.netlify.com/projects/openpolicyagent/deploys/697b0c54c5554a00080cd3f3
😎 Deploy Preview https://deploy-preview-8264--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Signed-off-by: Sebastian Spaink <sebastianspaink@gmail.com>
@anderseknert anderseknert enabled auto-merge (squash) January 29, 2026 07:29
@anderseknert anderseknert merged commit 0f48904 into open-policy-agent:main Jan 29, 2026
31 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.

json.match_schema() does not work reliable with array input and schema

2 participants