fix: handle sendLoginname failures in OIDC re-auth flow#91
Open
0xmc wants to merge 1 commit into
Open
Conversation
When a session has expired during the OIDC login callback, loginWithOIDCAndSession calls sendLoginname to redirect the user to re-authenticate. sendLoginname can throw (e.g. "Could not get domain", "Could not find identity provider", or a propagated ConnectError), and that call was not wrapped in a try/catch, unlike the createCallback call just below it. The unhandled rejection propagated out of the route handler, where Next.js redacts server error messages in production, so Sentry only ever saw a bare digest with no context. Wrap the call in try/catch, matching the same pattern already used in apps/login/src/app/login/route.ts, and report the real error to Sentry with tags/extra so future alerts carry useful context. The console.error line intentionally logs only the error message and correlating IDs (authRequest, sessionId), not the full error object, to keep pod logs terse; the full error still reaches Sentry via captureException. Add regression tests covering: the failure no longer throws, the failure is reported to Sentry, and the existing redirect-on-success behavior is unchanged.
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.
When a session has expired during the OIDC login callback, loginWithOIDCAndSession calls sendLoginname to redirect the user to re-authenticate. sendLoginname can throw (e.g. "Could not get domain", "Could not find identity provider", or a propagated ConnectError), and that call was not wrapped in a try/catch, unlike the createCallback call just below it. The unhandled rejection propagated out of the route handler, where Next.js redacts server error messages in production, so Sentry only ever saw a bare digest with no context.
Wrap the call in try/catch, matching the same pattern already used in apps/login/src/app/login/route.ts, and report the real error to Sentry with tags/extra so future alerts carry useful context. The console.error line intentionally logs only the error message and correlating IDs (authRequest, sessionId), not the full error object, to keep pod logs terse; the full error still reaches Sentry via captureException.
Add regression tests covering: the failure no longer throws, the failure is reported to Sentry, and the existing redirect-on-success behavior is unchanged.