Skip to content

fix: handle sendLoginname failures in OIDC re-auth flow#91

Open
0xmc wants to merge 1 commit into
mainfrom
fix/oidc-sendloginname-unhandled-rejection
Open

fix: handle sendLoginname failures in OIDC re-auth flow#91
0xmc wants to merge 1 commit into
mainfrom
fix/oidc-sendloginname-unhandled-rejection

Conversation

@0xmc

@0xmc 0xmc commented Jul 9, 2026

Copy link
Copy Markdown

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant