-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
partial eval: Improve support for cases where default values are not required #820
Comments
Where would this go? I'd be happy to give this a try, but I'm a bit lost as to where to start |
hey @srenatus, I've updated this issue to scope it better. I've created another issue (#823) to capture the other improvement we could make. The other issue will require a bit more groundwork. For this issue, the observation is that the default value is not required in the partial evaluation output, i.e., the query above will be undefined when all of the non-default rules are undefined, similarly, the query will be defined if any of the non-default rules are defined. The evaluator currently has a special case for partial evaluation of rules with a default value: https://github.com/open-policy-agent/opa/blob/master/topdown/eval.go#L1445. When the evaluator checks if the rule set has a default value, it can determine if the default value is required. In these cases, the default value is NOT required if the other term in the expression ( I think what needs to happen is the evaluator should plug
|
Previously, partial eval would always generate a support rule when it evaluated a rule with a default value. These changes tweak this behaviour so that support rules are only generated if the default value is required in the partial eval output. It's better to avoid generating support rules as it simplifies the assumptions that the consumer of partial eval can make. Fixes open-policy-agent#820 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Previously, partial eval would always generate a support rule when it evaluated a rule with a default value. These changes tweak this behaviour so that support rules are only generated if the default value is required in the partial eval output. It's better to avoid generating support rules as it simplifies the assumptions that the consumer of partial eval can make. Fixes #820 Signed-off-by: Torin Sandall <torinsandall@gmail.com>
Currently, OPA generates support rules for all rule sets that include a default rule, regardless of whether:
This issue focuses on the first problem.
For example:
Query (unknowns=[input]):
Policy:
In this case, the result of partial evaluation is:
Queries (1 total):
Support modules (1 total):
In this case, the default value is not actually required in the partial evaluation output (since true != false). OPA should avoid generating support rules in cases like this which will be common for Compile API integrations.
Related Issues: #812
The text was updated successfully, but these errors were encountered: