-
Notifications
You must be signed in to change notification settings - Fork 580
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
fix: do not show invalidSeverityThreshold error for HTTP 400 responses #4920
Conversation
I would consider adding a test here.. the fact that there are no existing tests doesn't mean we should continue with it. |
I added new tests for the entire file |
question: so I may be missing something, but how are invalid severity thresholds now reported? And where can I find an Acceptance Tests for that? |
There's an explicit I've tested and running cli/test/tap/severity-threshold.test.ts Line 47 in 351c7bd
I think the same error was added for 400 errors many years ago by mistake, so this should not influence the severity errors - but it will fix HTTP 400 bad requests. |
nitpick: that referenced test doesn't fail if the severity does NOT throw an error. Approving now, though. |
What does this PR do?
Fixes a misleading error message.
In c2399ae we assumed that all 400 responses returned by our backends are due to an incorrect severity threshold (eg
snyk test --severity-threshold=non-sense
).This is incorrect - the CLI calls into many different backend services and we can't assume anything about the reason of the failure.
Where should the reviewer start?
First understand how error messages are parsed/formatted here:
cli/src/lib/errors/legacy-errors.js
Lines 82 to 106 in 351c7bd
Then it should be clear that this line doesn't really make sense:
cli/src/lib/errors/legacy-errors.js
Line 56 in 351c7bd
If we do not provide a value for
400
above, then we'll use a generic error message, which should be more appropiate.How should this be manually tested?
generateMonitorDependenciesRequest
to return an invalid requestsnyk container monitor node:latest
, the result isInvalid severity threshold, please use one of low | medium | high | critical
An unknown error occurred. Please run with
-dand include full trace when reporting to Snyk
-d
gives: the following result (this is not usper nice, but is still better than giving misleading info)Any background context you want to provide?
Part of a customer ticket - the customer uses a proxy that returns a 400 error. Instead of showing the actual error we display a totally misleading message:
What are the relevant tickets?
Screenshots
N/A
Additional questions
N/A