Repository navigation
Conversation
The request-logging middleware picks level purely by status: every 4xx was Warn. On a public endpoint 404s are dominated by bots/scanners probing /.env, /HNAP1, /favicon.ico etc, flooding WARN (~1500 no-matching-operation lines observed) and burying actionable warnings. Extract levelForStatus and log 404 at Info; other 4xx stay Warn, 5xx stay Error. Adds a unit test. Refs e2b-dev#3783
AdaAibaby
requested review from
ValentaTomas,
dobrac and
jakubno
as code owners
November 2, 2026 05:06
This branch has not been deployed
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.
What
The shared request-logging middleware (
packages/shared/pkg/middleware/logging.go) picks the access-log level purely from the status code, so every 4xx is logged at WARN. On a public endpoint the 404 stream is dominated by bots/scanners probing/.env,/HNAP1,/favicon.ico,/robots.txt,/login, … — observed ~1500no matching operation was foundWARN lines on a dev api, burying the warnings that actually matter.This logs 404 at Info; other 4xx (401/403/429/validation) stay Warn, 5xx stays Error. Complements #3784 (which fixed the same external-scanner-noise-at-WARN pattern on the client-proxy side); this fixes it at the API's shared HTTP middleware.
Refs #3783.
Why 404 specifically
A 404 means the client asked for a route that doesn't exist — legitimate SDK/dashboard traffic hits real routes, so 404s are overwhelmingly external probes or typos, not an operational signal. Other 4xx can carry intent (auth failures, rate limiting, bad request bodies) and stay at Warn.
How
Extract
levelForStatus(status int, def zapcore.Level) zapcore.Leveland call it in the middleware. Behavior is identical except 404 moves from Warn to Info — response codes and everything else are unchanged.Test
TestLevelForStatusasserts the mapping across 2xx/3xx/404/400/401/403/429/5xx.go test ./packages/shared/pkg/middleware/passes.