Repository navigation
refactor(user): filter account linking errors in Sentry - #5078
Conversation
Only report 'LINKING-FAILED' errors to Sentry. Expected user errors such as 'ACCOUNT-ALREADY-LINKED' and 'PROVIDER-ALREADY-LINKED' are now suppressed to reduce noise in error monitoring. Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe Sentry-noise guard around Files Reviewed (1 file)
Verification notes: Confirmed against current HEAD ( Reviewed by kimi-k3 · Input: 35.5K · Output: 4.5K · Cached: 200.7K Review guidance: REVIEW.md from base branch |
Summary
linkAccountToExistingUserreported every account-linking failure to Sentry viacaptureException, including expected user errors likeACCOUNT-ALREADY-LINKED(user tried to link a provider account already attached to another Kilo user) andPROVIDER-ALREADY-LINKED. This produced noisy Sentry issues such asGET /api/auth/callback/githubAccount linking failed: ACCOUNT-ALREADY-LINKED.The NextAuth
signInhandler inserver.tsalready treats these codes as expected and skips Sentry, but the capture inlinkAccountToExistingUserfired unconditionally before that check. This PR guards thecaptureExceptionso onlyLINKING-FAILED(a genuine system error — the DB insert returned nothing) is reported. Expected errors still return normally and redirect the user to the appropriate error page.Verification
oxlintpasses (0 warnings, 0 errors) and existingmulti-auth.test.tscoverage oflinkAuthProviderToUsererror codes is unaffected. Full web typecheck could not complete within the CI-agent sandbox time limit.Visual Changes
N/A
Reviewer Notes
linkAuthProviderToUserreturns exactly three failure codes (ACCOUNT-ALREADY-LINKED,PROVIDER-ALREADY-LINKED,LINKING-FAILED), so the=== 'LINKING-FAILED'guard covers all unexpected cases.