From 7b4e3aba01bc8ac94ef2d07a9160deca8564b12a Mon Sep 17 00:00:00 2001 From: Inder Singh <85822513+singh-inder@users.noreply.github.com> Date: Thu, 17 Sep 2026 19:06:30 +0530 Subject: [PATCH] fix(studio): show service role key in ConnectSheet for projects using legacy keys (#50516) ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Bug fix #50515 ## What is the new behavior? ConnectSheet now falls back to the legacy `service_role` key for projects using legacy JWT keys. ## Summary by CodeRabbit * **Bug Fixes** * Improved secret-key resolution by falling back to the service key when a secret key is unavailable. * Prevented attempts to reveal a secret when no secret key identifier exists. --- .../components/interfaces/ConnectSheet/useConnectServerEnv.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/studio/components/interfaces/ConnectSheet/useConnectServerEnv.ts b/apps/studio/components/interfaces/ConnectSheet/useConnectServerEnv.ts index ab7128ea401..7de676027af 100644 --- a/apps/studio/components/interfaces/ConnectSheet/useConnectServerEnv.ts +++ b/apps/studio/components/interfaces/ConnectSheet/useConnectServerEnv.ts @@ -69,7 +69,7 @@ export function useConnectServerEnv(): UseConnectServerEnvResult { { enabled: canReadAPIKeys } ) const publishableKey = keys?.publishableKey?.api_key ?? keys?.anonKey?.api_key ?? '' - const secretKey = keys?.secretKey + const secretKey = keys?.secretKey ?? keys?.serviceKey const maskedValue = secretKey?.api_key ? `${secretKey.api_key.slice(0, 15)}${SECRET_MASK}` : 'your-secret-key' @@ -79,7 +79,7 @@ export function useConnectServerEnv(): UseConnectServerEnvResult { isLoading: isRevealing, reveal, clear, - } = useRevealedSecret({ projectRef, id: secretKey?.id }) + } = useRevealedSecret({ projectRef, id: secretKey?.id ?? undefined }) // toggle() and getSecretValue() can both decide to reveal before either // resolves (e.g. clicking "Reveal" and "Copy" in quick succession); share