opa
                                
                                
                                
                                    opa copied to clipboard
                            
                            
                            
                        Missing file error message ends up on STDOUT
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
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.
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? 🤔
Another option would be to make this configurable and default to stdout.
This issue has been automatically marked as inactive because it has not had any activity in the last 30 days. Although currently inactive, the issue could still be considered and actively worked on in the future. More details about the use-case this issue attempts to address, the value provided by completing it or possible solutions to resolve it would help to prioritize the issue.