fix: don't alert on expected OAuth session-not-found in callback - #279
Closed
claude[bot] wants to merge 1 commit into
Closed
fix: don't alert on expected OAuth session-not-found in callback#279claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
oauthController.Callback captured every gothic.CompleteUserAuth error via traceway.CaptureException, firing a CRITICAL alert. The gothic error "could not find a matching session for this request" is an expected, client-driven condition (the callback was reached without the short-lived session Begin writes: expired, replayed, or hit directly by a scanner) — the OAuth equivalent of a failed login, not a server fault. Skip capturing that error and the sibling "state token mismatch"; still redirect the user to the login error page, and still capture genuinely unexpected failures (token exchange, provider errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fixes #278
Root cause
oauthController.Callback(backend/app/controllers/oauth.controller.go:77) callsgothic.CompleteUserAuthand, on any error, reported it viatraceway.CaptureException— which surfaces as a new CRITICAL issue and fires a notification.The specific error, gothic's
"could not find a matching session for this request", is thrown byGetFromSessionwhen the callback request has no matching session value (session.Values["github"]is nil). This is an expected, client-driven condition, not a server fault: the callback was reached without the short-lived session thatBeginwrites (MaxAge=600→ 10 minutes). It happens when:defer Logouton success) or expired, or/api/auth/callback/githubendpoint directly.All of these are the OAuth equivalent of a failed/expired login. The user is already handled correctly (redirected to the login error page); the defect is only that the condition was categorized as a server exception, producing false-positive CRITICAL alerts.
Why it's not a functional break
Beginwrites and commits the session on its 307 redirect (theTransactionalmiddleware commits on 2xx–3xx), andCallbackreads and validates it.count=1,firstSeen == lastSeen) with no correlated DB errors, warn/error logs, distributed trace, or session — a systematic break would produce many occurrences.Fix
Skip
CaptureExceptionfor the benign gothic auth failures ("could not find a matching session for this request"and the sibling"state token mismatch", both stale-callback / expired-session / CSRF cases surfaced identically to the user). Still redirect to the login error page in all cases, and still capture genuinely unexpected failures (token exchange, provider errors). Added a unit test for the classification helper.gothic exposes these as plain
errors.Newstrings with no sentinels, so message matching is the only option; it's contained to one small helper.Verification
go build ./app/controllers/(default and-tags "transactional_pg telemetry_ch")go vet ./app/controllers/go test ./app/controllers/ ./app/services/— all pass, including the newTestIsExpectedOAuthAuthError.View details: /issues/2e16546cedb34a03