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

Exit code for unrecognized-format depends on --fail-severity #2149

Open
max-moritz opened this issue May 4, 2022 · 2 comments
Open

Exit code for unrecognized-format depends on --fail-severity #2149

max-moritz opened this issue May 4, 2022 · 2 comments
Labels
CLI CLI component enhancement New feature or request triaged

Comments

@max-moritz
Copy link

Describe the bug
I expected a nonzero exit code in any case when Spectral detects a file with unrecognized format and prints warning unrecognized-format The provided document does not match any of the registered formats [OpenAPI 2.0 (Swagger), OpenAPI 3.x, OpenAPI 3.0.x, OpenAPI 3.1.x]. However, the exit code depends on the value of the --fail-severity cmd line option.

I understand the concept of error, warn, info, hint levels and that with --fail-severity one can define for which levels a nonzero failure exit code shall be returned. I also realize that the unrecognized format scenario results in a warning. However, I expected that these levels refer solely to rule violations in the API being linted. But maybe my expectation is wrong... ;-)

To Reproduce
Run the following commands:

echo extends: spectral:oas > ruleset.yml
echo blah blah > invalid.yml
spectral lint -r ruleset.yml invalid.yml
echo $? # prints 0
spectral lint -r ruleset.yml invalid.yml --fail-severity warn
$ echo $? # prints 1

Expected behavior
Non-zero exit code in any case

Environment (remove any that are not applicable):

  • Library version: 6.3.0
@P0lip
Copy link
Contributor

P0lip commented May 4, 2022

Hey @max-moritz.
It's a rule internally, hence the behavior.
However, I totally agree with your reasoning, and the proposal you've made sounds more user-friendly than the existing implementation.

@pavelkornev
Copy link
Contributor

pavelkornev commented May 17, 2022

We would find it also useful if we can increase a level of severity of unrecognized-format to Error... This way Spectral will return non-zero error code automatically.

/related issue: #1124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI CLI component enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

4 participants