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

rego.v1 import does not enable future keywords in query compiler #6701

Closed
tsandall opened this issue Apr 18, 2024 · 0 comments · Fixed by #6706
Closed

rego.v1 import does not enable future keywords in query compiler #6701

tsandall opened this issue Apr 18, 2024 · 0 comments · Fixed by #6706

Comments

@tsandall
Copy link
Member

It seems the rego.v1 import does not enable the future keywords on the query compiler. For example:

This does not work:

torin:~$ opa eval --import rego.v1 '"x" in data'
{
  "errors": [
    {
      "message": "var _ is unsafe",
      "code": "rego_unsafe_var_error",
      "location": {
        "file": "",
        "row": 1,
        "col": 5
      }
    },
    {
      "message": "var in is unsafe (hint: `import future.keywords.in` to import a future keyword)",
      "code": "rego_unsafe_var_error",
      "location": {
        "file": "",
        "row": 1,
        "col": 5
      }
    }
  ]
}

However, this does:

torin:~$ opa eval --import future.keywords.in '"x" in data'
{
  "result": [
    {
      "expressions": [
        {
          "value": false,
          "text": "\"x\" in data",
          "location": {
            "row": 1,
            "col": 1
          }
        }
      ]
    }
  ]
}

This same issue applies anywhere the import should enable the keywords inside queries, e.g., the REPL, playground, etc.

johanfylling added a commit to johanfylling/opa that referenced this issue Apr 22, 2024
When `rego.v1` is in the list of imports directly applied on the `rego.Rego` SDK struct, this import, and it's effects, is applied to the query when parsed.
This change affects the `eval` and `bench` commands when the `--imports` flag is used.

Fixes: open-policy-agent#6701
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
ashutosh-narkar pushed a commit that referenced this issue Apr 22, 2024
When `rego.v1` is in the list of imports directly applied on the `rego.Rego` SDK struct, this import, and it's effects, is applied to the query when parsed.
This change affects the `eval` and `bench` commands when the `--imports` flag is used.

Fixes: #6701

Signed-off-by: Johan Fylling <johan.dev@fylling.se>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant