Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tester/runner: Fix panic'ing case in utility function. #5497

Merged
merged 1 commit into from Dec 21, 2022

Conversation

philipaconrad
Copy link
Contributor

This commit fixes a panic from a utility function in the opa test codepath. After the ref-heads change in #4660, this particular function could be fed a ref that it didn't know how to work with, such as the innocuous line a[0] := 1, and it would then panic.

This was fixed by returning a dummy value instead of panic'ing.

Fixes: #5496

@philipaconrad
Copy link
Contributor Author

Thanks for the quick approval, @ashutosh-narkar. I'm rebasing the PR to catch up with main, and will merge shortly.

tsandall
tsandall previously approved these changes Dec 21, 2022
Copy link
Member

@tsandall tsandall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing we're not testing this code path since the old version would panic. It's probably worth adding a rule that triggered the panic here: https://github.com/open-policy-agent/opa/blob/main/tester/runner_test.go#L59.

@philipaconrad
Copy link
Contributor Author

philipaconrad commented Dec 21, 2022

That should be easy enough to add. One second...

This commit fixes a panic from a utility function in the `opa test`
codepath. After the ref-heads change in open-policy-agent#4660, this particular
function could be fed a ref that it didn't know how to work with,
such as the innocuous line `a[0] := 1`, and it would then panic.

This was fixed by returning a dummy value instead of panic'ing.

Fixes: open-policy-agent#5496

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
@philipaconrad philipaconrad merged commit a08934d into open-policy-agent:main Dec 21, 2022
philipaconrad added a commit to philipaconrad/opa that referenced this pull request Dec 21, 2022
…gent#5497)

This commit fixes a panic from a utility function in the `opa test`
codepath. After the ref-heads change in open-policy-agent#4660, this particular
function could be fed a ref that it didn't know how to work with,
such as from the innocuous line `a[0] := 1`, and it would then panic.

This was fixed by returning a dummy value instead of panic'ing.

Fixes: open-policy-agent#5496

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
(cherry picked from commit a08934d)
philipaconrad added a commit that referenced this pull request Dec 21, 2022
This commit fixes a panic from a utility function in the `opa test`
codepath. After the ref-heads change in #4660, this particular
function could be fed a ref that it didn't know how to work with,
such as from the innocuous line `a[0] := 1`, and it would then panic.

This was fixed by returning a dummy value instead of panic'ing.

Fixes: #5496

Signed-off-by: Philip Conrad <philipaconrad@gmail.com>
(cherry picked from commit a08934d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opa test panics when array ref present in test
3 participants