opa
opa copied to clipboard
Improve rule conflict error
The following policy:
package play
p := 1
p.q := 2
p.r[s] := 3 { s := "s" }
will generate the error:
1 error occurred: policy.rego:3: rego_type_error: rule data.play.p conflicts with [data.play.p.q data.play.p.r[__local0__]]
This error has two points that can be improved:
- the rewritten var
__local0__is output instead ofsfor rulep.r[s]. - no location is given for the conflicting refs
data.play.p.qanddata.play.p.r[__local0__].
(2) might get very verbose if location data is added, especially if a rule is declared over multiple modules. A multi-line error might be appropriate:
1 error occurred: policy.rego:3: rego_type_error: rule data.play.p conflicts with:
rule data.play.p.q at policy1.rego:5, policy2.rego:12
rule data.play.p.r[s] at policy1.rego:7
the above error assumes an additional module that also declares rule play.p.q on line 12.