You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{15:50} /tmp ❯ curl -X POST -d "@input.json" 'http://localhost:8181/v1/data/example_rbac/user_has_role'
{"result":["widget-writer"]}%
Back to allow
{15:50} /tmp ❯ curl -X POST -d "@input.json" 'http://localhost:8181/v1/data/example_rbac/allow'
{"result":true}%
🎉
Success!
I should then be able to do the same thing with ?partial
Actual Behavior
The response I get back for any cached ?partial query is the result of the last one to have been partially evaluated:
First query for allow
{15:50} /tmp ❯ curl -X POST -d "@input.json" 'http://localhost:8181/v1/data/example_rbac/allow?partial'
{"result":true}%
Now for user_has_role
{15:51} /tmp ❯ curl -X POST -d "@input.json" 'http://localhost:8181/v1/data/example_rbac/user_has_role?partial'
{"result":["widget-writer"]}%
Back to allow
{15:51} /tmp ❯ curl -X POST -d "@input.json" 'http://localhost:8181/v1/data/example_rbac/allow?partial'
{"result":["widget-writer"]}%
🤔
Additional Info
It looks like the problem is that we share a compiler for all of the cached partially evaluated rego's and each time we do the partial evaluation we store the freshly generated module on the compiler with id __partialresult__ and the same data.partial.__result__ query. Now when any subsequent evaluations occur for a cached partial query path we end up using that same module, regardless of whether or not it was actually the partial module associated with the query path originally.
The text was updated successfully, but these errors were encountered:
Previously we let it use the default namespace, which meant that
every cached evaluation would use the same query on the compiler..
which isn't correct. They need to be unique per path.
We'll now use a hash of the path (since it needs to be a valid var).
While doing this the logic for the Rego opts was refactored in
`makeRego` to only define the list a single time.. this should help
reduce the risk of any regressions in the future.
Fixes: open-policy-agent#2247
Signed-off-by: Patrick East <[email protected]>
Previously we let it use the default namespace, which meant that
every cached evaluation would use the same query on the compiler..
which isn't correct. They need to be unique per path.
We'll now use a hash of the path (since it needs to be a valid var).
While doing this the logic for the Rego opts was refactored in
`makeRego` to only define the list a single time.. this should help
reduce the risk of any regressions in the future.
Fixes: #2247
Signed-off-by: Patrick East <[email protected]>
Expected Behavior
Starting up the server with some test policies:
policy.rego
data.json
I should then be able to make multiple queries to the server with them affecting the results of each other:
input.json
First query for
allow
Now for
user_has_role
Back to
allow
🎉
Success!
I should then be able to do the same thing with
?partial
Actual Behavior
The response I get back for any cached
?partial
query is the result of the last one to have been partially evaluated:First query for
allow
Now for
user_has_role
Back to
allow
🤔
Additional Info
It looks like the problem is that we share a compiler for all of the cached partially evaluated rego's and each time we do the partial evaluation we store the freshly generated module on the compiler with id
__partialresult__
and the samedata.partial.__result__
query. Now when any subsequent evaluations occur for a cached partial query path we end up using that same module, regardless of whether or not it was actually the partial module associated with the query path originally.The text was updated successfully, but these errors were encountered: