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

File path in AST locations different between --data and --bundle loaded files #1796

Closed
tsandall opened this issue Sep 27, 2019 · 0 comments
Closed
Assignees

Comments

@tsandall
Copy link
Member

Simple example:

x.rego:

package x

p { not a }   # a is unsafe

Output differs depending on whether -b or -d is used:

torin:~/temp$ opa eval -d $PWD 'data'
{
  "errors": [
    {
      "message": "var a is unsafe",
      "type": "ast",
      "code": "rego_unsafe_var_error",
      "location": {
        "file": "/home/torin/temp/x.rego",
        "row": 3,
        "col": 9
      }
    }
  ]
}
torin:~/temp$ opa eval -b $PWD 'data'
{
  "errors": [
    {
      "message": "var a is unsafe",
      "type": "ast",
      "code": "rego_unsafe_var_error",
      "location": {
        "file": "/x.rego",
        "row": 3,
        "col": 9
      }
    }
  ]
}

Inside of the VS code extension this makes a difference because the file paths for -d option are clickable whereas the file paths for -b are not.

For -b files loaded out of a directory (i.e., not out of a tarball), I think it would be better to prefix with the -b flag value. For the tarball case, it's a bit trickier.

patrick-east added a commit to patrick-east/opa that referenced this issue Dec 17, 2019
When reading a bundle from a directory we should be using the full
system path for the module files. This helps greatly with reducing
complexity of trying to read error messages. It also makes the
integration with tools like VSCode work better as they can provide
links from the console output file paths to the file in question.

This will not affect bundles loaded from tarballs.

Fixes: open-policy-agent#1796
Signed-off-by: Patrick East <east.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants