[PR #8693] feat(sso): Add logging for when code validation fails in oidc callback #16396

Closed
opened 2026-04-13 10:30:41 -05:00 by GiteaMirror · 0 comments
Owner

Original Pull Request: https://github.com/better-auth/better-auth/pull/8693

State: closed
Merged: Yes


When code exchange fails, the error object is thrown:

b1be9cf61b/packages/core/src/oauth2/validate-authorization-code.ts (L154-L161)

But further up the call stack this gets swallowed:

b1be9cf61b/packages/sso/src/routes/sso.ts (L1603-L1612)

This is not a BetterFetchError, so this redirect is missed and a generic error replaces it.

The generic error is fine, but it'd be really great to see what is happening here, as OIDC provider errors are lost otherwise.

**Original Pull Request:** https://github.com/better-auth/better-auth/pull/8693 **State:** closed **Merged:** Yes --- When code exchange fails, the error object is thrown: https://github.com/better-auth/better-auth/blob/b1be9cf61b1e6a61bcab476397b0d5eaff0785f0/packages/core/src/oauth2/validate-authorization-code.ts#L154-L161 But further up the call stack this gets swallowed: https://github.com/better-auth/better-auth/blob/b1be9cf61b1e6a61bcab476397b0d5eaff0785f0/packages/sso/src/routes/sso.ts#L1603-L1612 This is not a `BetterFetchError`, so this redirect is missed and a generic error replaces it. The generic error is fine, but it'd be really great to see what is happening here, as OIDC provider errors are lost otherwise.
GiteaMirror added the pull-request label 2026-04-13 10:30:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16396