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

Undefined function in nested call not caught during type checking #661

Closed
tsandall opened this issue Mar 12, 2018 · 0 comments
Closed

Undefined function in nested call not caught during type checking #661

tsandall opened this issue Mar 12, 2018 · 0 comments
Assignees
Labels

Comments

@tsandall
Copy link
Member

For example

$ opa run
OPA 0.7.2-dev (commit 4f8ea30c, built at 2018-03-12T23:03:15Z)

Run 'help' to see a list of commands.

> count(deadbeef(100))
no error(s)

However, other kinds of type errors are caught:

> count(sum(100))
1 error occurred: 1:7: rego_type_error: sum: invalid argument(s)
	have: (number, ???)
	want: (any<set[number], array[number]>, number)
@tsandall tsandall added the bug label Mar 12, 2018
@tsandall tsandall added this to the v0.8 milestone Mar 12, 2018
@tsandall tsandall self-assigned this Mar 12, 2018
tsandall added a commit to tsandall/opa that referenced this issue Mar 21, 2018
Originally this looked like a type checking bug, but in fact it was
related to the safety check.

Previously, we filtered out safety errors for generated vars because
they are meaningless to the user. This led to unsafe queries being
allowed in some edge cases. For example: sum() > 1 would be
expanded to sum(__local0__); __local0__ > 1. The first expression is
unsafe but this would not be reported.

This change ensures that the compiler reports an error in all cases.

With this change, safety errors for generated vars are turned into error
messages indicating the expression is unsafe. Above, there would be a
single error indicating the expression "sum() > 1" is unsafe.

Fixes open-policy-agent#661

Signed-off-by: Torin Sandall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant