forked from open-policy-agent/opa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update compiler to check for partially replaced virtual docs
Previously the compiler only checked whether the with keyword was applied to non-input/data documents or functions. This mean that the with keyword target could be used to partially replace virtual documents. Unfortunately the evalutor does not support this kind of replacement. For example, in v0.10.6: > p = {"a": 1, "b": 2} Rule 'p' defined in package repl. Type 'show' to see rules. > p = x with p.a as 100 +---------------+ | x | +---------------+ | {"a":1,"b":2} | +---------------+ These changes update the compiler to walk the rule tree and check if the with target would replace a virtual document and generates an error in that case. Allowing the with keyword to partially replace virtual documents comes with its own set of problems. For example, suppose we defined a virtual document 'p' and queried for 'p' using the with modifier (e.g., 'p with p.foo as 2'): p[x] = 1 { expr1 x = "foo" } What should the value of 'p' be if an error occurs during evaluation of 'expr1'? It's arguable that the error should be masked because the value generated by the rule would be replaced. Unfortunately, the evaluator may not know the value of 'x' when the error occurs so it doesn't have enough information to decide. Signed-off-by: Torin Sandall <[email protected]>
- Loading branch information
Showing
2 changed files
with
39 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters