-
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
Confusing difference between eval --input flag and api input body #4218
Comments
Thanks for the detailed writeup about your experience @LucasRoesler 👍 Yeah, this definitely comes up from time to time, and I agree that it's an easy one to miss when starting out with OPA. One thing to note here is that you can use the This is detailed in the OPA REST API documentation, but perhaps we could do better surfacing this elsewhere in the docs as well. If you have any suggestions as to where, that'd be great! |
Thank for the suggestion, I will take a look at it. |
Somewhat unrelated (i.e. it won't help here), but wouldn't it be nice if
i.e. supporting prefixes to wrap the input document. |
Looks good to me @srenatus! I had no idea |
Yup. (With some caveats on windows #4174...)
|
Cool (except for the Windows issue)! Is this documented somewhere? I didnt see it mentioned in |
Let's say "hinted at", https://github.com/open-policy-agent/opa/blob/main/cmd/run.go#L100-L103 |
That's nice. We should copy that into the |
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. |
The OPA server will now print a warning when the Closing as resolved. |
Short description
Hi, I recently started researching OPA for a project and started by creating some sample policies and writing a short introduction for my teammates.
I initially started with the
to quickly iterate on my example policies.
I got everything working and overall I am pretty excited, but the same policy and input would fail when an API call
Steps To Reproduce
To reproduce I created a demo rule
and this input file
Running with the CLI produces
But with the server using
opa run -s -b . -w
, the same input file fails as a requestbut it would return results like this
Expected behavior
Ideally, I would expect the the same file to work for both
opa eval
and as a request to the opa server.Alternatively, some kind of validation error or logging from the API would also have been helpful. I am not sure it is 100% possible for OPA to know my rule requires an
input
but certainly it could validate that I sent extra unknown fields in my request and either return an validation error or maybe some logging or perhaps some other data while tracing the request to give a hint that the request body might be wrong. It took me a long time to think about usingprint(input)
and find out that it was undefined mostly because I missed the print function when looking for it in the reference.Additional context
Now knowing the issue, i was able to go back and see that this is addressed in the docs For example, it is highlighted here
![image](https://user-images.githubusercontent.com/891889/149201336-f01f8c63-5f94-4f61-b1ab-5d26a2467bfb.png)
I think the issue I had is that I had already jumped into experimenting with
opa eval
so I was no longer following along with the Intro docs and so I thought I knew what I was doing.This is definitely human error
The text was updated successfully, but these errors were encountered: