Skip to content

fix: Remove console.log on invalid status codes#829

Open
Juan Ibiapina (juanibiapina-ctfl) wants to merge 2 commits into
mainfrom
remove-console-log
Open

fix: Remove console.log on invalid status codes#829
Juan Ibiapina (juanibiapina-ctfl) wants to merge 2 commits into
mainfrom
remove-console-log

Conversation

@juanibiapina-ctfl
Copy link
Copy Markdown

@juanibiapina-ctfl Juan Ibiapina (juanibiapina-ctfl) commented Jun 2, 2026

createValidateStatusCode unconditionally 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.

Comment thread src/utils/http.ts

export const createValidateStatusCode = (allowedStatusCodes: number[]) => (response: Response) => {
if (!allowedStatusCodes.includes(response.statusCode)) {
console.log(response.body)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug might be better here instead of removing it completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants