Closed balcanuc closed 4 months ago
Seems like this is related to Regorus enabling strict built-in errors by default. If you pass --non-strict
it works:
$ ./target/release/examples/regorus eval -d examples/bug.rego -i ./examples/bug.json data.test --non-strict
{
"result": [
{
"expressions": [
{
"value": {
"foo": null,
"some_id": {
"count_value": "<undefined>"
}
},
"text": "data.test",
"location": {
"row": 1,
"col": 1
}
}
]
}
]
}
And you also get same error on OPA Playground if you enable strict built-in errors by via "Options > Built-in Error Behaviour > Strict".
Thanks for reporting this, @balcanuc.
As @unexge pointed out, Regorus defaults to strict evaluation - raising errors in many scenarios. Using the non-strict
mode would suppress the errors and generate undefined
instead, just like OPA.
I noticed in the output supplied by @unexge that "undefined" has propagated into the object instead of making the object expression itself undefined. This is a bug.
@balcanuc A note about strict
mode. OPA is moving towards their v1
release which will introduce many breaking changes.
See https://www.openpolicyagent.org/docs/latest/policy-language/#the-regov1-import.
most Strict mode constraints and checks are implied and enforced. See the strict mode constraints and checks table for details.
Examples such as yours might error out by default in OPA v1.
In object expressions, "undefined" values are added to the object instead of making the expression itself undefined.
ORIGINAL TITLE: Different behavior of Regorus vs OPA for when invoking count
---- Original Description --- Regorus it is behaving differently for
count(expr)
in case that the expression to be evaluated isnull
orscalar
. The OPA is doing evaluation like the expression is undefined but regorus evaluation fails with error.Repro scenario:
Step 1: Create bug.rego file with following content
Step 2: Create bug.json file with following content
Step 3: run command below (assuming you already run
cargo install --example regorus --path .
The output is
However, if you go to the https://play.openpolicyagent.org/ and fill in the content of the
bug.rego
into the input the content ofbug.json
and clickEvaluate
, you'll get following outputIs it possible to change the regorus so the evaluation output to be similar to OPA evaluation?