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

Update type checker to hide undefined function errors if possible #2091

Closed
tsandall opened this issue Feb 10, 2020 · 0 comments · Fixed by #2231
Closed

Update type checker to hide undefined function errors if possible #2091

tsandall opened this issue Feb 10, 2020 · 0 comments · Fixed by #2231
Assignees

Comments

@tsandall
Copy link
Member

tsandall commented Feb 10, 2020

The type checker currently reports "undefined function" errors if a rule/query refers to a function that itself contains type errors. If an error is introduced into a function that's called in a large number of locations the errors reported by OPA can be extremely noisy and make it difficult to understand the problem (especially since by default OPA will only report up to 10 errors before stopping.)

In cases where "undefined function" errors are due to the referenced function itself containing an error, the type checker can drop/ignore the error. One simple way to implement this would be to simply drop/ignore "undefined function" errors if there is an existing error in the type checking pass.

Example:

package x

p {
	f(1)
}

f(x) {
	max("foo")  # max requires an array
}
ashutosh-narkar added a commit to ashutosh-narkar/opa that referenced this issue Mar 27, 2020
Earlier if a rule/function contained an error, the type checker would not update the env with subsequent independent rules resulting in errors such as "undefined functions". This change add erroneous rules/functions to the env to avoid such type errors.

Fixes open-policy-agent#2155

Fixes open-policy-agent#2091

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
@ashutosh-narkar ashutosh-narkar self-assigned this Mar 27, 2020
ashutosh-narkar added a commit that referenced this issue Mar 30, 2020
Earlier if a rule/function contained an error, the type checker would not update the env with subsequent independent rules resulting in errors such as "undefined functions". This change add erroneous rules/functions to the env to avoid such type errors.

Fixes #2155

Fixes #2091

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants