The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix(studio): silence status page errors when incident.io isn't configured (#51315)
Alaister Young16bd06dfb889
diff --git a/apps/studio/data/platform/status-page-query.ts b/apps/studio/data/platform/status-page-query.tsindex fbbf1425b74..53d1c1ff5a0 100644--- a/apps/studio/data/platform/status-page-query.ts+++ b/apps/studio/data/platform/status-page-query.ts@@ -16,9 +16,6 @@ async function getStatusPage(signal?: AbortSignal): Promise<StatusPageResponse>})if (!response.ok) {- const errorText = await response.text()- console.error('[getStatusPage] Failed:', response.status, errorText)-let retryAfter: number | undefinedconst retryAfterHeader = response.headers.get('Retry-After')if (retryAfterHeader !== null) {diff --git a/apps/studio/lib/api/status-page.test.ts b/apps/studio/lib/api/status-page.test.tsindex 41dec153f52..3d202b78cc4 100644--- a/apps/studio/lib/api/status-page.test.ts+++ b/apps/studio/lib/api/status-page.test.ts@@ -133,6 +133,29 @@ describe('getStatusPage', () => {await expect(getStatusPage()).rejects.toThrow()})+ test('missing widget URL outside production → empty payload, isDegraded true', async () => {+ vi.stubEnv('INCIDENT_IO_WIDGET_URL', '')+ vi.stubEnv('NODE_ENV', 'development')+ const errorSpy = vi.spyOn(console, 'error')++ const { getStatusPage } = await import('./status-page')+ const result = await getStatusPage()++ expect(result.isDegraded).toBe(true)+ expect(result.data.ongoing_incidents).toEqual([])+ expect(result.data.in_progress_maintenances).toEqual([])+ expect(result.data.scheduled_maintenances).toEqual([])+ expect(errorSpy).not.toHaveBeenCalled()+ })++ test('missing widget URL in production → throws', async () => {+ vi.stubEnv('INCIDENT_IO_WIDGET_URL', '')+ vi.stubEnv('NODE_ENV', 'production')++ const { getStatusPage } = await import('./status-page')+ await expect(getStatusPage()).rejects.toThrow('INCIDENT_IO_WIDGET_URL is not set')+ })+test('missing API key / status page ID → succeeds with default annotations everywhere, isDegraded true', async () => {vi.stubEnv('INCIDENT_IO_WIDGET_URL', WIDGET_URL)vi.stubEnv('INCIDENT_IO_API_KEY', '')diff --git a/apps/studio/lib/api/status-page.ts b/apps/studio/lib/api/status-page.tsindex 5ecd394d0c6..7f0166def86 100644--- a/apps/studio/lib/api/status-page.ts+++ b/apps/studio/lib/api/status-page.ts@@ -24,6 +24,14 @@ const MAX_RETRIES = 2export type StatusPageResult = { data: StatusPageResponse; isDegraded: boolean }+const EMPTY_STATUS_PAGE: StatusPageResponse = {+ page_title: 'Supabase Status',+ page_url: 'https://status.supabase.com/',+ ongoing_incidents: [],+ in_progress_maintenances: [],+ scheduled_maintenances: [],+}+const LinkedResponseIncidentsSchema = z.object({incidents: z.array(z.object({ id: z.string(), linked_at: z.string() })),})@@ -149,9 +157,13 @@ async function fetchResponseIncident(apiKey: string, id: string): Promise<Respon}export async function getStatusPage(): Promise<StatusPageResult> {+ // Missing incident.io config is expected in local dev, so only treat it as an error in production+ const isProduction = process.env.NODE_ENV === 'production'+const widgetUrl = process.env.INCIDENT_IO_WIDGET_URLif (!widgetUrl) {- throw new InternalServerError('INCIDENT_IO_WIDGET_URL is not set')+ if (isProduction) throw new InternalServerError('INCIDENT_IO_WIDGET_URL is not set')+ return { data: EMPTY_STATUS_PAGE, isDegraded: true }}const widget = await fetchWidget(widgetUrl)@@ -162,7 +174,7 @@ export async function getStatusPage(): Promise<StatusPageResult> {const statusPageId = process.env.INCIDENT_IO_STATUS_PAGE_IDif (!apiKey || !statusPageId) {- console.error('INCIDENT_IO_API_KEY or INCIDENT_IO_STATUS_PAGE_ID is not set')+ if (isProduction) console.error('INCIDENT_IO_API_KEY or INCIDENT_IO_STATUS_PAGE_ID is not set')return { data: annotateWidget(widget, new Map(), modeFieldIds), isDegraded: true }}