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

Docs on default functions should mention risk of undefined arguments #6265

Closed
anderseknert opened this issue Oct 2, 2023 · 2 comments · Fixed by #6806
Closed

Docs on default functions should mention risk of undefined arguments #6265

anderseknert opened this issue Oct 2, 2023 · 2 comments · Fixed by #6806

Comments

@anderseknert
Copy link
Member

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.

@ashutosh-narkar
Copy link
Member

Can you please provide an example of this case?

@anderseknert
Copy link
Member Author

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.

@ashutosh-narkar ashutosh-narkar added this to Backlog in Open Policy Agent via automation Oct 3, 2023
anderseknert added a commit to anderseknert/opa that referenced this issue Jun 10, 2024
Open Policy Agent automation moved this from Backlog to Done Jun 11, 2024
anderseknert added a commit that referenced this issue Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants