WithPartialEval losses r.Runtime
Version: 0.64.1
In practice it is not possible to use opa.runtime().env with partial eval.
This is a test to reproduce issue:
func TestPartialEvalLoosesRuntime(t *testing.T) {
module := `
package test
x = opa.runtime()
`
noPartial, _ := rego.New(
rego.Query("data.test.x"),
rego.Runtime(ast.BooleanTerm(true)),
rego.Module("", module),
rego.Package("foo"),
).PrepareForEval(context.Background())
partial, _ := rego.New(
rego.Query("data.test.x"),
rego.Runtime(ast.BooleanTerm(true)),
rego.Module("", module),
rego.Package("foo"),
).PrepareForEval(context.Background(), rego.WithPartialEval())
rs1, _ := noPartial.Eval(context.Background())
rs2, _ := partial.Eval(context.Background())
if !rs1.Allowed() {
t.Fatal()
}
if !rs2.Allowed() {
t.Fatal()
}
}
Hi there! and thanks for filing this issue.
I believe that's the case for all non-deterministic built-in functions: https://github.com/open-policy-agent/opa/blob/main/ast/builtins.go#L310
I remember some discussions about allowing these to be evaluated at compile time vs. eval time, but I don't remember the specifics. @srenatus, perhaps?
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.