Skip to content
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

Input Documentation Unclear #1293

Closed
Arkessler opened this issue Mar 27, 2019 · 5 comments · Fixed by #1344
Closed

Input Documentation Unclear #1293

Arkessler opened this issue Mar 27, 2019 · 5 comments · Fixed by #1344

Comments

@Arkessler
Copy link

Expected Behavior

Documentation at: https://github.com/open-policy-agent/opa/blob/master/docs/content/docs/how-does-opa-work.md should have a more accurate example of a valid input document

Example input document:

{
  "input": {
    "method": "GET",
    "path": "/servers/s2",
    "user": "alice"
  }
}

Actual Behavior

Example input document:

{
  "method": "GET",
  "path": "/servers/s2",
  "user": "alice"
}

As is, the example seems to suggest the "input" key is optional. This is especially misleading when passing input through a json file.

Steps to Reproduce

  1. Create a file, input.json, containing:
{
  "method": "GET",
  "path": "/servers/s2",
  "user": "alice"
}
  1. Create a policy file, policy.rego, containing;
package input.example

import input

requests[request] {
    request= input[_]
}
  1. Load policy into opa and make a document request using --input @input.json
  2. Result will not contain expected data
{
    "result": {
        "requests": []
    }
}
@tsandall
Copy link
Member

tsandall commented Mar 28, 2019

@Arkessler thanks for filing this. I propose we add a paragraph in that section after the example policy that show show you can invoke the policy. For example:

To supply the input document, query OPA using the POST method.

POST /v1/data/example/allow HTTP/1.1
Content-Type: application/json
{
  "input": {
    "method": "GET"
    ...
  }
}

If you'd be able to contribute something like this to the documentation, that would be much appreciated!

@Arkessler
Copy link
Author

Will do! Just going to take a bit of time before I can get to it

danielpops added a commit to danielpops/opa that referenced this issue Apr 17, 2019
patrick-east pushed a commit that referenced this issue Apr 17, 2019
 #1293

Signed-off-by: Daniel Popescu <danielpops@gmail.com>
@artbegolli
Copy link

Happy for me to update the Query API docs to clarify this as well?

@tsandall
Copy link
Member

tsandall commented Jun 11, 2019 via email

@artbegolli
Copy link

artbegolli commented Jun 11, 2019

There's an example request under Execute a Simple Query - I've just started experimenting with OPA and feel like the example should include the input document as mentioned here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants