Closed andrehaland closed 3 years ago
🤦 I should have guessed... https://github.com/open-policy-agent/opa/commit/251dcc58d0e74b49feeb195ea6fb489edd3f8868#r51373293
I'm on it. You're correct with the fix, but I'll add a test somewhere, too.
@andrehaland would you mind reviewing that? we'll cut a release when it's in.
@andrehaland would you mind reviewing that? we'll cut a release when it's in.
Done
Thank you 😃
✔️ 0.29.2 is here, fixing this.
Expected Behavior
OPA to not panic
Actual Behavior
OPA panics when trying to assign non existent input data to a variable inside a function
Steps to Reproduce the Problem
With the following package
OPA panics with v0.29.1 and not in v0.28.0:
Additional Info
Looking at the source code where Go panics
github.com/open-policy-agent/opa/topdown.evalFunc.eval(0xc000184000, 0xc0001a78c0, 0x3, 0x4, 0xc0001a7940, 0x3, 0x4, 0xc0001d8a80, 0x5619580, 0xc00000f601) /Users/runner/work/opa/opa/topdown/eval.go:1509 +0x5ac
I see that the memoize feature added a direct lookup on index 0 before check ifir.Empty()
https://github.com/open-policy-agent/opa/blob/a57fc72536973f54ea33a3fbf13ef0e5ff417caf/topdown/eval.go#L1509-L1513I would guess that moving this assignment to after the empty check solves the issue, but I have not tested this yet. I will test this locally and raise a PR if it fixes the issue