-
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
Warn when input attributes is missing in /v1/data body #4386
Comments
@anderseknert Can I work on this please? like others, I have also been bitten by this issue in the past. |
Sure! Let me know if you need any help along the way, either here or in the #development channel on the OPA slack. |
from a quick parse, looks like we want to address the issue here ? |
Yeah, at least you have the |
This change adds an api_usage_warning when input attribute is missing in the request to /v1/data Fixes: open-policy-agent#4386 Signed-off-by: Alam <afaaqalam@gmail.com> server: remove url from warning msg Signed-off-by: Alam <afaaqalam@gmail.com> server: remove warning for GET requests to v1/data; fix tests Signed-off-by: Alam <afaaqalam@gmail.com>
This change adds an api_usage_warning when input attribute is missing in POST requests to /v1/data Fixes: #4386 Signed-off-by: Alam <afaaqalam@gmail.com>
Every now and then we see users new to OPA missing the fact that
/v1/data
requires the JSON request body to wrap theinput
document, ala:{"input": {"x": "y"}}
. Unless e.g. default assignment is used, OPA currently returns just an empty response for a request missing the "input" wrapper, i.e.{"x": "y"}
... it's easy to see why this would be, given how people likely have worked on their policy in the Rego Playground or usingopa eval
before running the server.It would be an improvement if we informed the user of what's missing! Suggested response might look something like:
Note that while it's tempting to return a 400 response, this would both break a lot of existing integrations, and would need to differentiate between input missing entirely (i.e. no JSON body) and JSON body but with missing
input
attribute. For that reason we'll keep the 200 response but with an added warning.The text was updated successfully, but these errors were encountered: