Hi. Is there a way to get more detailed error mess...
# help
b
Hi. Is there a way to get more detailed error message. I am getting
failed to load test suite: failed to unmarshal JSON: proto: syntax error (line 1:183): unexpected token {
and I am sure I made some mistake in yaml file (I have validated it and it is valid yaml) and I am sure it is not going to be last time, so I am looking for a way to get a sense of what is wrong. I am running
docker run -it -v (pwd)/policies:/policies -v (pwd)/tests:/tests <http://ghcr.io/cerbos/cerbos:latest|ghcr.io/cerbos/cerbos:latest> compile /policies --tests /tests --verbose
. Thanks.
I found what was the concrete problem (I didn’t make
expected
a list), but original question still stands. Additionally - is there a schema for test files? I have configured one for policies, but I am not aware of one for test files.
c
Hi. Yes, this is an area we want to improve and provide better error messages. It's still in the works though. You can find the schema for the test suites at https://api.cerbos.dev/latest/cerbos/policy/v1/TestSuite.schema.json and you should be able to use it with schema-aware editors like VSCode to validate your files. We have some documentation on that here: https://docs.cerbos.dev/cerbos/latest/policies/authoring_tips.html#_editing_policies
b
@Charith (Cerbos) ah, great, thanks for the link for TestSuite schema, I did not see it on documentation page (I did set up VS code for policies). This greatly helps 🙂 .
Looking forward to better error messages 🙂 .
From error message, it seems to me that yaml is compiled to JSON. Is that true? Is there a way to see JSON that is generated from YAML somehow?
c
Well, actually the YAML gets converted to protobufs via JSON. We don't currently have a way to output the intermediate representation. You can use a tool like
yq
to convert YAML to JSON and vice versa if that's useful.
b
Thanks.