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

Missing file error message ends up on STDOUT #6749

Open
janorn opened this issue May 15, 2024 · 3 comments
Open

Missing file error message ends up on STDOUT #6749

janorn opened this issue May 15, 2024 · 3 comments
Labels

Comments

@janorn
Copy link

janorn commented May 15, 2024

Short description

Using opa against a non existent rego files returns with an error message on STDOUT and errcode 2.
I would think such an error really should be sent to STDERR. We struggled with this in a pipeline because STDOUT was consumed.

  • OPA Version: 0.64.1

Steps To Reproduce

$ ./opa eval --format pretty --data file.rego tfplan.json
1 error occurred: stat file.rego: no such file or directory

$ ./opa eval --format pretty --data file.rego tfplan.json > /dev/null
$

$ ./opa eval --format pretty --data file.rego tfplan.json 2> /dev/null
1 error occurred: stat file.rego: no such file or directory

Expected behavior

$ ./opa eval --format pretty --data file.rego tfplan.json > /dev/null
1 error occurred: stat file.rego: no such file or directory

Additional context

@janorn janorn added the bug label May 15, 2024
@ashutosh-narkar
Copy link
Member

This is an error coming from the rego package and it's handled differently. This is why it goes to stdout. This is printed by the presentation package. We can probably change this behavior based on whether the result contains an error.

@anderseknert
Copy link
Member

Agreed, this is unexpected, and stderr would be the right channel for output here.

If we "always" did this, I suppose there's a real risk that there are scripts out there relying on finding the error message on stdout? But since the eval command could print errors to either stdout or stderr, I'm not sure that sending one particular error to a different output than before should be considered a breaking change? 🤔

@ashutosh-narkar
Copy link
Member

Another option would be to make this configurable and default to stdout.

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

No branches or pull requests

3 participants