Unexpected response from partial evaluation call #522
Replies: 8 comments 7 replies
-
Just checking back to see if there are any thoughts on my previous post? If it helps I can create a PR on the OPA project for you to evaluate further. |
Beta Was this translation helpful? Give feedback.
-
@srenatus @johanfylling any thoughts on this? |
Beta Was this translation helpful? Give feedback.
-
What does it return? |
Beta Was this translation helpful? Give feedback.
-
Sorry about that. I wasn't sure what the easiest way was to attach the value of presult to this thread which is why I ended up taking a screenshot and attaching a link to the test case. Thanks for the tip on how to make it easier to share that information. I noticed the same behavior with a nil value for the unknowns as well. I wasn't sure if that was the intended behavior or not. In our service code the unknowns value will always be non nil so that behavior isn't so important to our use case. I definitely agree that this issue appears to be related to the use of opa.runtime() as we recently added a call to it when we were switching over to use a JWT in our policy. Given your assessment would you classify this as a bug or missing functionality in partial evaluation? If so, should I open an issue for it? |
Beta Was this translation helpful? Give feedback.
-
I have not tried the Compile API as we don't intend to use it in our use case. Yes, I was planning to just define the key as a variable instead as a workaround I hadn't considered putting it in its own package. Not sure if there is any benefit of doing that over just defining the variable in the same package. One of things that I feel I'm struggling a bit with is the Document model. I've read the following link, however I feel I don't have a full understanding of it. For example, with Dynamic Composition data.policies can reference the policies defined in the retrieved bundle. Based on the doc, I understand your example with variables but why the policies are there is a bit less clear. Is there a way to view the document that OPA builds to evaluate a decision. That might help me understand what properties are available. |
Beta Was this translation helpful? Give feedback.
-
Yes, that is helpful! I had tried the -pretty option before but had not changed the query string to be 'data'. Thanks for the tip! I started using the opa eval command for dynamic composition which helped significantly with testing Dynamic Composition given I didn't see a way to define multiple packages in the Rego Playground. When you mentioned the Compile API earlier I thought you were referring to the API mentioned at this link which is REST based. Thinking about it some more, I'm wondering if you might have been referring to the 'opa' binary (i.e opa eval command) as the "compile api". If so, I can give that a try and report back. |
Beta Was this translation helpful? Give feedback.
-
Similar behavior occurs when using opa eval. For example: Using this policy: import future.keywords.if default allow := false grant if { And the following input: And the following environment variable set: Running the following command: produces the following output:
Where as running this command:
Produces this output: Does that information help you decide if this is a bug or a new feature request? I think I still lean toward this being a (missing functionality) bug as I have not found any documentation suggesting partial evaluation does not support the use of "opa.runtime()". |
Beta Was this translation helpful? Give feedback.
-
The company I work for is looking to support open source projects that we use by contributing back to the projects. Therefore we are open to contributing the requested functionality back to OPA if the project owners feel this is something that is within the grasp of a new user and the maintainers support our contribution effort. Please let me know if this is something you are open to. |
Beta Was this translation helpful? Give feedback.
-
I'm seeing an unexpected response when making an opa.Partial(...) call in the test case linked below.
https://github.com/open-policy-agent/opa/compare/main...robhafner:opa:discussion1?expand=1
A similar call (in the same test) to opa.Decision(...) results in the value true being returned. However, the call to Partial(...) does not result in the partial Queries field being an empty array as a result of OPA being able to make a non-conditional decision. Which is what I would expect based upon the information found in the following link:
https://www.openpolicyagent.org/docs/latest/rest-api/#unconditional-results-from-partial-evaluation
Could this be a bug in the behavior of the partial decision evaluation? Or am I overlooking something?
Beta Was this translation helpful? Give feedback.
All reactions