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

planner: non-string ref keys break #5252

Closed
srenatus opened this issue Oct 14, 2022 · 0 comments · Fixed by #5257
Closed

planner: non-string ref keys break #5252

srenatus opened this issue Oct 14, 2022 · 0 comments · Fixed by #5257
Assignees
Labels

Comments

@srenatus
Copy link
Contributor

package play

a[0] = true

This is a consequence of #4660. opa eval is fine, opa eval -t wasm -d x.rego is

panic: interface conversion: ast.Value is ast.Number, not ast.String

goroutine 1 [running]:
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefDataExtent(0xc0001a20c0, 0xc0004a94e0, 0x0, 0xc0004a95c0)
	/Users/stephan/Sources/open-policy-agent/opa/internal/planner/planner.go:1921 +0xbd7
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefDataExtent(0xc0001a20c0, 0xc0004a94c0, 0xc0004a95a0, 0xc0004a9520)
	/Users/stephan/Sources/open-policy-agent/opa/internal/planner/planner.go:1926 +0x8ec
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefData(0x1017ad040?, 0x0?, 0xc0002fb560?, {0xc0002fb160?, 0x2?, 0xa5b861490f3fda36?}, 0x1d6654ba0036aff0?, 0x4?)
	/Users/stephan/Sources/open-policy-agent/opa/internal/planner/planner.go:1627 +0x2e5
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRefData(0xc0001a20c0, 0xc0004a94a0, 0xc0004a9540, {0xc0002fb160?, 0x2, 0x2}, 0x1, 0xc0004a9520)
	/Users/stephan/Sources/open-policy-agent/opa/internal/planner/planner.go:1777 +0xe69
github.com/open-policy-agent/opa/internal/planner.(*Planner).planRef(0xc0001a20c0, {0xc0002fb160?, 0x2, 0x2}, 0x2?)
	/Users/stephan/Sources/open-policy-agent/opa/internal/planner/planner.go:1580 +0x533
@srenatus srenatus added the bug label Oct 14, 2022
@srenatus srenatus self-assigned this Oct 14, 2022
srenatus added a commit to srenatus/opa that referenced this issue Oct 17, 2022
The compiler ensures that all the keys we see there are scalars. For strings,
nothing changes -- they're handled just like before -- but this now also allows
numbers and booleans.

An example policy that exploded with a panic before is

    package p
    a[0] = true

when querying the full extent of `data.p` or `data.p.a`.

Fixes open-policy-agent#5252.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
srenatus added a commit that referenced this issue Oct 17, 2022
The compiler ensures that all the keys we see there are scalars. For strings,
nothing changes -- they're handled just like before -- but this now also allows
numbers and booleans.

An example policy that exploded with a panic before is

    package p
    a[0] = true

when querying the full extent of `data.p` or `data.p.a`.

Fixes #5252.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
byronic pushed a commit to byronic/opa that referenced this issue Oct 17, 2022
…policy-agent#5257)

The compiler ensures that all the keys we see there are scalars. For strings,
nothing changes -- they're handled just like before -- but this now also allows
numbers and booleans.

An example policy that exploded with a panic before is

    package p
    a[0] = true

when querying the full extent of `data.p` or `data.p.a`.

Fixes open-policy-agent#5252.

Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com>
Signed-off-by: Byron Lagrone <byron.lagrone@seqster.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant