opa
opa copied to clipboard
Docs on default functions should mention risk of undefined arguments
The docs on the default keyword describes the new default function feature like:
The value of a default function follows the same conditions as that of a default rule.
That's not really the case though, as default functions provides no guarantess as for evaluating in case an undefined attribute is provided in any of the arguments passed. This is likely not what most would expect from having used default values for rules, so provided this can't be fixed it needs to be clearly documented that default functions provide no guarantees similar to default rules.
Can you please provide an example of this case?
Sure:
package p
default x(_) := "default"
x_is := x(input.undefined)
$ opa eval -f pretty -d p.rego data.p.x_is
undefined
The root cause being the same as described in #1877, but now in one more place where people likely/rightly would share the same expectation. Fixing anything would be great, but also breaking. So, clearly documenting the behavior here seems like the best course of action now.