opa: 'opa build -t wasm' with functions defined on entrypoint fails with "undefined ref"
Short description
Everything builds and tests pass. When attempting to build for WASM:
opa build -e "reproduction" -t wasm reproduction.rego
error: 1 error occurred: reproduction.rego:1: rego_type_error: undefined ref: data.reproduction.func_decide
data.reproduction.func_decide
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
have: (any) => object<bool: boolean>
Problem observed on 0.38.0, 0.37.2
Steps To Reproduce
reproduction.rego
package reproduction
func_not(y) = {"bool":false} {
y.bool
} else = {"bool":true}
func_decide(something) = func_not(something)
reproduction_test.rego
package reproduction
test_repro {
func_decide({"bool":false}).bool
}
Expected behavior
Successful WASM build or test build failing or tests not passing.
Additional context
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (11 by maintainers)
Commits related to this issue
- Moving around functions to avoid Wasm build bug. https://github.com/open-policy-agent/opa/issues/4411 — committed to kevinswiber/spego by kevinswiber 2 years ago
I’m glad you’ve got a workaround; this still is something we should fix. I’d have to dig in a bit to understand the rationale behind the current way things are done 🔍
May I ask about your use case? I’m always curious about people using wasm 😅