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

Support rules for undefined partial documents not generated correctly #2492

Closed
tsandall opened this issue Jun 25, 2020 · 0 comments
Closed
Labels

Comments

@tsandall
Copy link
Member

tsandall commented Jun 25, 2020

PE generates support rules for partial documents if the reference requires the full extent of the document. However, if none of the rules that generate the document are defined, the document should be considered empty (not undefined). Currently PE does not generate the correct output in this case (it generates a reference to a non-existent/undefined virtual document.)

Example:

data.foo.p = x
package foo

p[1] { input; false }

In this case, when PE runs on the query above, the body of p is undefined (because of the expression "false") however the current output is an empty set (undefined). We can fix this by unifying the other term in the query with the empty value for the virtual document (i.e., set() or {}).

@tsandall tsandall added the bug label Jun 25, 2020
tsandall added a commit to tsandall/opa that referenced this issue Jun 25, 2020
This commit fixes an issue in partial eval whereby OPA would generate
an incorrect expression referring to a non-existent/undefined virtual
document. This would occur if an expression referenced the full extent
of a virtual document generated by partial rules and those partial
rules were all undefined. In that case, the reference needs to be
unified with the default (empty) value for that virtual document.

Fixes open-policy-agent#2492

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

No branches or pull requests

1 participant