fix(supabase): warn instead of throw for unrecognized sb_ API key subtypes#2526
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAPI key validation now uses Sequence Diagram(s)sequenceDiagram
participant SupabaseClient
participant checkApiKeyFormat
participant Console
SupabaseClient->>checkApiKeyFormat: Validate supabaseKey format
checkApiKeyFormat->>Console: Warn once for unknown sb_ subtype
checkApiKeyFormat-->>SupabaseClient: Continue without throwing
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. 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 |
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
5fd614c to
c44d4a6
Compare
…47960) Adds a contract test that runs `createProjectSupabaseClient()` against the real `@supabase/supabase-js` for each Supabase API key format (temporary, publishable, secret, legacy JWT), asserting that client construction succeeds. Also replaces the placeholder key fixtures in the existing unit tests with realistically shaped ones. Previously the tests mocked the SDK entirely and used keys that don't resemble real formats, so an SDK version that rejects a valid key at construction (as `@supabase/supabase-js` 2.110.4 and 2.110.5 did, reverted in #47945 and fixed in supabase/supabase-js#2526) passed CI unnoticed; with this test, such a regression fails on the dependency bump PR itself. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Added coverage confirming project clients work with temporary, publishable, secret, and legacy API key formats. * Updated test scenarios to use realistic temporary API key values. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This PR updates `@supabase/supabase-js` to v2.110.6. **Source**: supabase-js-stable-release --- ## Release Notes ## v2.110.6 ## 2.110.6 (2026-07-15) ### 🩹 Fixes - **postgrest:** type hinted self-referencing embeds as arrays ([#2520](supabase/supabase-js#2520)) - **realtime:** forward opts to send() in track() ([#2490](supabase/supabase-js#2490)) - **supabase:** warn instead of throw for unrecognized sb_ API key subtypes ([#2526](supabase/supabase-js#2526)) ### ❤️ Thank You - Franco Kaddour @FrancoKaddour - Katerina Skroumpelou @mandarini This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
This PR updates @supabase/*-js libraries to version 2.110.6. **Source**: supabase-js-stable-release **Changes**: - Updated @supabase/supabase-js to 2.110.6 - Updated @supabase/auth-js to 2.110.6 - Updated @supabase/realtime-js to 2.110.6 - Updated @supabase/postgest-js to 2.110.6 - Refreshed pnpm-lock.yaml --- ## Release Notes ## v2.110.6 ## 2.110.6 (2026-07-15) ### 🩹 Fixes - **postgrest:** type hinted self-referencing embeds as arrays ([#2520](supabase/supabase-js#2520)) - **realtime:** forward opts to send() in track() ([#2490](supabase/supabase-js#2490)) - **supabase:** warn instead of throw for unrecognized sb_ API key subtypes ([#2526](supabase/supabase-js#2526)) ### ❤️ Thank You - Franco Kaddour @FrancoKaddour - Katerina Skroumpelou @mandarini ## v2.110.5 ## 2.110.5 (2026-07-14) ### 🩹 Fixes - **supabase:** avoid edge runtime warning ([#2522](supabase/supabase-js#2522)) ### ❤️ Thank You - Vaibhav @7ttp ## v2.110.4 ## 2.110.4 (2026-07-14) ### 🩹 Fixes - **functions:** stop sending API key in Authorization header for function calls ([#2511](supabase/supabase-js#2511)) - **realtime:** encode broadcast header fields as UTF-8 ([#2516](supabase/supabase-js#2516)) ### ❤️ Thank You - Katerina Skroumpelou @mandarini - Pedro Henrique ## v2.110.3 ## 2.110.3 (2026-07-13) ### 🩹 Fixes - **auth:** preserve pkce verifier ([#2513](supabase/supabase-js#2513)) - **postgrest:** pin tstyche target off floating latest ([#2509](supabase/supabase-js#2509)) ### ❤️ Thank You - Katerina Skroumpelou @mandarini - Vaibhav @7ttp ## v2.110.2 ## 2.110.2 (2026-07-09) ### 🩹 Fixes - **auth:** clear local session on signout failures ([#2504](supabase/supabase-js#2504)) ### ❤️ Thank You - Luc Peng This PR was created automatically. Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com>
Description
Relaxes the API key format check in
createClient()so that it never throws. Temporary keys (sb_temp_...) are now recognized and accepted silently, and any other unrecognizedsb_key subtype logs a one-timeconsole.warninstead of failing client construction.What changed?
packages/core/supabase-js/src/lib/fetch.ts: replacedassertSupportedApiKey()(which threw for anysb_key other thansb_publishable_.../sb_secret_...) withcheckApiKeyFormat():sb_temp_...keys are accepted silently.sb_subtype logs a one-timeconsole.warn(deduplicated per subtype) suggesting an SDK upgrade, and the client proceeds. The key value is never included in the warning.sb_publishable_.../sb_secret_...keys are unaffected.packages/core/supabase-js/src/SupabaseClient.ts: constructor call site updated to the new function. An empty key still throws (supabaseKey is required.).Authorization: Beareron Edge Function calls. Temporary and unrecognizedsb_subtypes keep the legacy behavior (apikeyheader plusAuthorization: Bearerfallback), which is what these keys relied on before the validation was introduced.apikeyplusAuthorization: Bearerfallback on both the regular and the Edge Functions fetch paths.docs/MIGRATION.md: removed the "Unrecognized API key formats now throw" section. With the throw gone there is no user action to document; the rest of the "Edge Functions auth headers" section from fix(functions): stop sending API key in Authorization header for function calls #2511 still applies and is untouched.Why was this change needed?
Versions
2.110.4and2.110.5threw synchronously in theSupabaseClientconstructor for anysb_key that was notsb_publishable_.../sb_secret_...(a future-proofing guard added in #2511). Thesb_key family can grow beyond what any released SDK version knows about, so hard-failing at construction breaks clients that are given valid keys of a newer subtype, such as the temporarysb_temp_...keys. The SDK is not the authority on key validity: with this change, an unrecognized and genuinely invalid key surfaces as an auth error from the server, while an unrecognized but valid key keeps working, with a one-time console warning that an SDK upgrade may be needed.Screenshots/Examples
Before (
2.110.4and2.110.5):After:
Breaking changes
None. This removes a constructor throw, so it strictly widens the set of accepted inputs. Keys that worked before continue to work identically.
Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formattingAdditional notes
assertSupportedApiKeywas exported fromsrc/lib/fetch.tsbut never re-exported from the package entry point, so renaming it tocheckApiKeyFormatdoes not change the public API.@supabase/supabase-js2.110.1 in Revert "feat: update @supabase/*-js libraries to v2.110.5" (#47918) supabase#47945 to avoid this throw; that pin can be lifted once this fix is in a stable release.