fix(api): classify client-disconnect body-read errors separately from auth failures - #3414
Open
AdaAibaby wants to merge 1 commit into
Open
fix(api): classify client-disconnect body-read errors separately from auth failures#3414AdaAibaby wants to merge 1 commit into
AdaAibaby wants to merge 1 commit into
Conversation
… auth failures
kin-openapi reads the entire request body (io.ReadAll) before invoking
any auth function. Under high concurrency the server ReadTimeout or the
client SDK timeout can fire during that read, producing a net.Error that
kin-openapi wraps in SecurityRequirementsError. processCustomErrors then
formats it with securityErrPrefix, ErrorHandler calls telemetry.ReportError
(OTel error status + WARN log), and the response goes out as 400 — all of
which falsely indicates an authentication failure.
Detect RequestError{Reason:"reading failed"} with an underlying net.Error
in processCustomErrors and return it under a new clientDisconnectPrefix.
ErrorHandler handles this prefix early: records a span event via
telemetry.ReportEvent (informational, not error), and responds 499 without
adding to c.Errors — so the logging middleware emits a plain WARN with the
route path rather than the misleading SecurityRequirementsError message.
This makes client-disconnect events visible and queryable in metrics (by
499 vs 400/401/403) without polluting auth-failure dashboards and alerts.
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.
Closes #3413
Summary
clientDisconnectPrefixconstant topackages/api/internal/utils/error.goprocessCustomErrors: detectRequestError{Reason:"reading failed"}with an underlyingnet.Errorand return it under the new prefix — preventing it from being reported as an auth failureErrorHandler: handle the new prefix before the telemetry/c.Error path — record a span event viatelemetry.ReportEvent(informational, not error), respond 499, skipc.ErrorsWhy
kin-openapireads the full request body (io.ReadAll) before calling any auth function. Under high concurrency the serverReadTimeout: 10scan expire while goroutines queue, producingnet.Errorwrapped inSecurityRequirementsError. Without this fix those network timeouts are logged as WARN with aSecurityRequirementsErrormessage, counted as 400 auth errors in metrics, and set OTel span error status — all misleading.Test plan
go build ./packages/api/...SecurityRequirementsErrorWARN lines are emitted for client disconnectsSecurityRequirementsErrorlogged as before/cc @jakubno @dobrac @ValentaTomas @arkamar @tvi Looking forward to your code review.