open-policy-agent / opa

Open Policy Agent (OPA) is an open source, general-purpose policy engine.
https://www.openpolicyagent.org
Apache License 2.0
9.56k stars 1.33k forks source link

Loading JSON array as data reports "bad document type" — should be more specific #6803

Closed anderseknert closed 3 months ago

anderseknert commented 3 months ago

data.json

[1, 2, 3]
opa run --server data.json
error: load error: 1 error occurred during loading: data.json: bad document type

While I immediately knew what was wrong, the "bad document type" error isn't helpful for anyone not familiar with what's expected for a data document (i.e. an object). We should update the error message to explain what's expected.