conflicting rule for data path
after POSTing a policy with a default value
#230
-
Hi OPA community I'm writing a thin wrapper over OPA server in order to validate user-fed data & policies before posting them in the prod server. To do so, when receiving a new policy, I do the following steps:
This is fine (albeit open for much optimization) on paper, but what happens in real life is different. When POSTing this policy to a brand new
To my surprise, the
I can list the policy correctly. But then when POSTing the next policy, my 3 steps procedure above creates files as expected, but the
How comes POSTing a policy also updates To reproduce:
Edit: using opa 0.42, and had the issue on 0.41 as well. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @valbisson! And thanks for reaching out 😃 The "Data API" should not be mistaken for serving only "static" JSON data such as that provided in a With that said, I'm not sure I understand why you need to GET the policies and data from a running OPA instance? If your users provide their policies, data, and possibly tests as well.. why not just accept those files as they are, run |
Beta Was this translation helpful? Give feedback.
-
Hi @anderseknert , thanks for the quick answer! I did misunderstand how the data API was serving both types of documents. It appears that posting the policy creates the virtual data, which I transform back into a base document when I pull & dump it in a file, causing the collision with the conflicting data path reported above. As a solution, I'll try to store data (documents or patches) and policies upstream from the opa server, and validate from these, rather than pull them back each time. As you suggested, right? (I can't blindly push them as they may depend on data/policies from other users, ie not be testable out of context). |
Beta Was this translation helpful? Give feedback.
Hi @valbisson! And thanks for reaching out 😃
The "Data API" should not be mistaken for serving only "static" JSON data such as that provided in a
data.json
file. In fact, the data API is what serves pretty much all decisions OPA makes! See the docs on the OPA document model to learn more about base documents vs. virtual documents, and how they both contribute to building the OPAdata
document.With that said, I'm not sure I understand why you need to GET the policies and data from a running OPA instance? If your users provide their policies, data, and possibly tests as well.. why not just accept those files as they are, run
opa check --strict
,opa test
, and so on, before packaging them in…