opa icon indicating copy to clipboard operation
opa copied to clipboard

difference in output for wasm vs rego

Open srenatus opened this issue 2 years ago • 3 comments

$ echo 123 | opa eval -I -fpretty 'input.foo with input.foo as input' -twasm
undefined
$ echo 123 | opa eval -I -fpretty 'input.foo with input.foo as input'       
123

I first suspected some query rewrite mistake, but it seems like this also happens when the expression is part of a rule body:

# with.rego
package x

p := y {
    y := input.foo with input.foo as input
}
$ echo 123 | opa eval -I -fpretty -d with.rego data.x.p -twasm
undefined
$ echo 123 | opa eval -I -fpretty -d with.rego data.x.p             
123

srenatus avatar Oct 11 '23 08:10 srenatus

The plot thickens (does it?!)

$ echo 1 | opa eval -I -fpretty 'input with input.x as input' -twasm 
1 error occurred: internal_error: opa_number_as_float: illegal ref
$ echo "foo" | opa eval -I -fpretty 'input with input.x as input' -twasm
"foo"
$  echo '{"y":"foo"}' | opa eval -I -fpretty 'input.x with input.x as input' -twasm
{
  "y": "foo"
}

so it works if input is an object that we can merge input.x into... 🤔

srenatus avatar Oct 11 '23 08:10 srenatus

While digging into this, I've found a way to trap the VM 😅

$ echo | opa eval -I -fpretty '1 with input.foo as 2' -twasm  
1 error occurred: internal_error: trapped at opa_eval/eval/opa_object_insert/__opa_object_insert
$ echo | opa eval -I -fpretty '1 with input.foo as 2'       
1

looks like insufficient input validation of .... input.

srenatus avatar Oct 11 '23 12:10 srenatus

This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.

stale[bot] avatar Nov 10 '23 16:11 stale[bot]