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

The rego_version field is not getting respected in the REPL #6872

Closed
tsandall opened this issue Jul 15, 2024 · 0 comments · Fixed by #6885
Closed

The rego_version field is not getting respected in the REPL #6872

tsandall opened this issue Jul 15, 2024 · 0 comments · Fixed by #6885
Labels

Comments

@tsandall
Copy link
Member

tsandall commented Jul 15, 2024

It seems the REPL has trouble with the rego_version field:

torin:~/scratch/rego-v1-exp$ ls -al
total 8
drwxr-xr-x   3 torin  staff    96 Jul 15 15:07 .
drwxr-xr-x@ 51 torin  staff  1632 Jul 15 14:22 ..
-rw-r--r--   1 torin  staff    33 Jul 15 15:05 x.rego

x.rego is v1 compatible.

torin:~/scratch/rego-v1-exp$ cat x.rego
package foo

p := 7 if { 3 < 4 }

Building a bundle with --v1-compatible and then running the REPL with the bundle produces an error:

torin:~/scratch/rego-v1-exp$ opa build --v1-compatible x.rego
torin:~/scratch/rego-v1-exp$ opa run -b bundle.tar.gz
OPA 0.67.0-dev (commit b8a7809d9975d54b6d675f66300da3da6d89b99b-dirty, built at 2024-07-02T13:11:57Z)

Run 'help' to see a list of commands and check for updates.

> data
2 errors occurred:
bundle.tar.gz/x.rego:3: rego_parse_error: var cannot be used for rule name
bundle.tar.gz/x.rego:3: rego_parse_error: rule name conflicts with built-in function

Note opa run -s -b ... and opa eval work fine.

EDIT:

You can run workaround this REPL bug by specifying opa run --v1-compatible ... when starting the REPL. This works as long as all bundles you are loading are v1 compatible.

@tsandall tsandall added the bug label Jul 15, 2024
ashutosh-narkar added a commit to ashutosh-narkar/opa that referenced this issue Jul 23, 2024
This change updates the repl so that the modules in the
provided bundle are parsed based on the `rego_version` attribute
in the bundle manifest. Currently that is ignored which leads
to parsing failures.

Fixes: open-policy-agent#6872

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
ashutosh-narkar added a commit that referenced this issue Jul 23, 2024
This change updates the repl so that the modules in the
provided bundle are parsed based on the `rego_version` attribute
in the bundle manifest. Currently that is ignored which leads
to parsing failures.

Fixes: #6872

Signed-off-by: Ashutosh Narkar <anarkar4387@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant