fix(specs): correct third-party auth error propagation behavior - #86
Conversation
The spec claimed a rejecting/throwing accessToken callback falls back to the anon key, same as returning null. That doesn't match supabase-js (fetchWithAuth in lib/fetch.ts calls the callback unguarded — a rejection propagates and fails the request; only a null return triggers the anon-key fallback). Split the two cases and add a Notes section stating implementations must not swallow callback errors into null, since that silently downgrades an authenticated request to an anonymous one instead of surfacing the failure.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
Included review availability: Your plan includes up to 1 review per rolling hour; 0 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe third-party authentication specification states that a Merge Risk: ⚪ Minimal · up to This is a localized specification correction clarifying authentication error propagation, with no production code changes or merge-blocking risk remaining after normal checks and review. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Repeated the point already made in the Behavior paragraph above it.
…lowing them (#1236) * fix(supabase): propagate access-token provider errors instead of swallowing them `adaptRequest` converted any error from resolving the access token — including one thrown by a configured `options.auth.accessToken` third-party auth provider — into `nil` via `try?`, so the request would silently go out under the anon key instead of failing. Only `AuthError.sessionMissing` (no signed-in user, the expected case) should fall back to the anon key; every other error (a network failure refreshing the session, or a throwing custom `accessToken` provider) must fail the request instead of downgrading it to an anonymous one. Flagged by CodeRabbit on #1233, and cross-checked against supabase-js and supabase-flutter, both of which already propagate these errors rather than swallowing them (flutter's `AuthHttpClient` explicitly documents this: "Throw the error instead of making an API request with an expired token"). Also see supabase/sdk#86, which corrects the capability spec to match. * refactor(supabase): move sessionMissing handling into accessTokenProvider Per @spydon's review on #1236: `adaptRequest` shouldn't need to know which auth errors are benign. Move the `catch AuthError.sessionMissing` into `accessTokenProvider` itself, so every caller — `adaptRequest` and the Realtime `accessToken` closure via `_getAccessToken()` — gets the same "no session falls back to nil, everything else propagates" behavior for free, instead of each caller needing its own catch. The Realtime closure previously had no such handling at all, so this also fixes it falling back consistently with REST/Storage/Functions.
🤖 I have created a release *beep* *boop* --- ## [1.2.0](v1.1.1...v1.2.0) (2026-08-20) ### Features * **auth:** add concurrent PKCE flow id capability ([#91](#91)) ([bd6d972](bd6d972)) ### Bug Fixes * **specs:** correct third-party auth error propagation behavior ([#86](#86)) ([ccc2fbb](ccc2fbb)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Summary
specs/client/authentication_integration/third_party_auth.mdcurrently says a rejecting/throwingaccessTokencallback falls back to the anon key, the same as returningnull:That doesn't match supabase-js, which I'm treating as the reference implementation here. In
fetchWithAuth(packages/core/supabase-js/src/lib/fetch.ts), the token getter is called unguarded:No try/catch — a rejecting callback propagates and fails the request. Only a
nullreturn triggers the anon-keyAuthorizationfallback.flutter'sAuthHttpClient.send()follows the same pattern (unguardedawait _getAccessToken()), and its_getAccessToken()explicitly rethrows session errors with the comment "Throw the error instead of making an API request with an expired token."This PR:
nullcase (anon-key fallback, unchanged) from the reject/throw case (must propagate and fail the call) in the spec's Behavior section.nullon the callback, since that silently downgrades an authenticated request to an anonymous one instead of surfacing the failure.This came up while reviewing supabase-swift#1233, where the Functions client's access-token closure used
try?, converting any error (including one from a configuredaccessTokenprovider) intonil. Cross-checking JS/Flutter/Python confirmed JS and Flutter both propagate the error; this spec should reflect that as the source of truth so other SDKs (including Swift) can be checked against it going forward.Test plan
npm run validatepasses inscripts/capability-matrix