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

Inconsistent JSON output on errors #482

Closed
ievgenii-shepeliuk opened this issue Nov 17, 2023 · 1 comment · Fixed by #817
Closed

Inconsistent JSON output on errors #482

ievgenii-shepeliuk opened this issue Nov 17, 2023 · 1 comment · Fixed by #817
Labels
bug Something isn't working tooling

Comments

@ievgenii-shepeliuk
Copy link

Hello

Let's say we have file test.rego with following content,

package test

default allow := true

Running regal with JSON format regal lint --format json test.rego - the successful output will be

{
  "violations": [],
  "summary": {
    "files_scanned": 1,
    "files_failed": 0,
    "rules_skipped": 0,
    "num_violations": 0
  }
}

Let's introduce a syntax error into test.rego, so it becomes

package test

def ault allow := true

Running regal with JSON format once again gives inconsistent output

error(s) encountered while linting: errors encountered when reading files to lint: 2 errors occurred:
test.rego:3: rego_parse_error: var cannot be used for rule name
test.rego:3: rego_parse_error: var cannot be used for rule name

The inconsistency is that error format is not JSON.
It makes a difficulty when creating Editor/IDE plugin that tries to parse JSON for the list of error.
Since in this case there's no JSON and error has no predefined format.

@anderseknert
Copy link
Member

That's an excellent point 👍 I'll take a look at how OPA does this, as ideally we'd provide the same JSON error output as OPA does for errors that originate in OPA (like the parser error above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tooling
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants