fix: Remove console.log on invalid status codes#829
Open
Juan Ibiapina (juanibiapina-ctfl) wants to merge 2 commits into
Open
fix: Remove console.log on invalid status codes#829Juan Ibiapina (juanibiapina-ctfl) wants to merge 2 commits into
Juan Ibiapina (juanibiapina-ctfl) wants to merge 2 commits into
Conversation
|
|
||
| export const createValidateStatusCode = (allowedStatusCodes: number[]) => (response: Response) => { | ||
| if (!allowedStatusCodes.includes(response.statusCode)) { | ||
| console.log(response.body) |
There was a problem hiding this comment.
debug might be better here instead of removing it completely
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createValidateStatusCodeunconditionally calls console.log(response.body) before throwing HTTPError on any unexpected status code. This bypasses any structured logger in the consuming application and writes raw JSON directly to stdout.In our Grafana each line of the JSON body is ingested as a separate log entry at error level with no extractable message field, causing a lot of noise.
I don't know what the goal of this console.log is, so I just removed it
:) but let me know if I missed something.
This change also adds the first unit tests for
createValidateStatusCode, including an explicit assertion that no stdout output occurs when the error path fires.