studio-error-handling

द्वारा supabase

Supabase Studio के लिए त्रुटि प्रदर्शन और समस्या निवारण पैटर्न। इसका उपयोग तब करें जब

npx skills add https://github.com/supabase/supabase --skill studio-error-handling

Studio Error Handling Pattern

Full architecture, SQLSTATE predicates, and mapping walkthrough: apps/studio/components/interfaces/ErrorHandling/README.md

How it works

handleError() → throws tagged StudioError → React Query catches → ErrorMatcher / AlertError renders UI
  • Tagged errors: handleError (@/data/fetchers) throws Effect Data.TaggedError instances (_tag, fault: user | platform | third_party | studio, reason, classifiedBy: rule | default, retryable, service, plus legacy message, code, requestId, …). Check with isStudioError(e) from @/lib/errors/studio-errors, never instanceof; StudioError is a union type only.
  • API vs non-API classifiers (data/error-classification.ts): classifyResponseError({ message, code }) is for HTTP API responses only (ERROR_PATTERNS win, else 5xx PlatformError, 4xx UnclassifiedApiError, no status UnexpectedError — never pass a made-up status). classifyError(e) handles everything else (tagged passes through, AbortError → RequestAborted, browser fetch failure → NetworkUnreachable, else UnexpectedError). Successful JSON GETs still empty after recovery reject from the fetch layer as MalformedResponseError (normalizeEmptyBodyResponse) without hitting handleError (reportQueryError still reports it).
  • SQL errors: executeSql runs pg-meta errors through classifySqlResponseError: user/AI SQL becomes UserSqlError (never sent to Sentry); Studio SQL becomes StudioSqlError (redacted message, static queryName required; marked fault: 'user', reason: 'user_input' when isUserFaultSqlState accepts the SQLSTATE via composable isUserFaultForValues (typed values: filters, row edits) or isUserFaultForSql (embedded SQL: policies, functions) in data/error-classification.ts).
  • Privacy & Sentry sampling: the class decides privacy (UserSqlError never sent, StudioSqlError redacted), while ERROR_ROUTING (lib/errors/error-routing.ts) maps every tag + fault to { sentrySampleRate } (SAMPLE_NEVER / SAMPLE_USER_FAULT / SAMPLE_OTHER / SAMPLE_OWNED / SAMPLE_ALWAYS, looked up via getErrorRouting). reportStudioError tags sample_rate (enforced in beforeSend) and sets errorEventId.
  • Reporting timing: QueryCache/MutationCache onError (reportQueryError) reports once after the final retry using sentryContext and alwaysCapture remembered by handleError. Pass reportImmediately: true to handleError only for callers outside React Query.

Key files

FilePurpose
apps/studio/data/error-patterns.tsERROR_PATTERN_MAP (Map<ErrorConstructor, RegExp>) — regex lives here, never in UI components
apps/studio/lib/errors/studio-errors.tsTagged error classes, StudioError union type, isStudioError
apps/studio/data/error-classification.tsclassifyResponseError, classifyError, classifySqlResponseError, predicates
apps/studio/lib/errors/error-routing.tsERROR_ROUTING table per tag and fault, getErrorRouting
apps/studio/components/interfaces/ErrorHandling/ErrorMatcher.tsxLooks up error class in error-mappings.tsx and renders troubleshooting UI
apps/studio/components/interfaces/ErrorHandling/error-mappings.tsxMap<ErrorConstructor, ErrorMapping> ({ id, Troubleshooting })
apps/studio/components/interfaces/ErrorHandling/errorMappings/ConnectionTimeout.tsxReference troubleshooting component (including AI Assistant debug button wiring)
apps/studio/components/interfaces/ErrorHandling/TroubleshootingSections.tsxReusable accordion section components
apps/studio/components/interfaces/ErrorHandling/TroubleshootingAccordion.tsxAccordion wrapper with telemetry

Which component

SituationUse
Query failed and page/section cannot render its data (default across Studio)AlertError from @/components/ui/AlertError
Error may be a classified class with troubleshooting steps (e.g. timeout)ErrorMatcher from @/components/interfaces/ErrorHandling/ErrorMatcher — pass fallback for unclassified errors
Mutation failedThe mutation hook's default onError toast (toast.error from sonner) — don't render an alert (see studio-queries)

AlertError (default)

if (isError) return <AlertError error={error} subject="Failed to retrieve invoices" />
  • Phrase subject as Failed to <verb> <thing> and pass projectRef in project context to pre-fill the support link. 503 responses are reworded automatically.
  • For StudioErrors, getErrorPresentation (AlertError.utils.ts) applies tag/fault defaults (caller props win): displays requestId, errorEventId ("before sampling"), and Copy details (formatErrorDetails strips formattedError, metadata, cause, SQL, and SQL error messages). fault: 'user' hides support/IDs/copy; offline NetworkUnreachable shows a dedicated offline message.
  • Use additionalActions for retry/navigation; use hideContactSupport only when support cannot help on a non-user fault. Prefer early return for primary data and inline {isError && <AlertError … />} for secondary panels.
  • System-fault assumption: AlertError's default copy for plain or non-user-fault errors (including unclassified 4xxs) tells users to refresh/contact support — don't use it blindly for mutation or client-side user-input errors; use the mutation's onError toast or actionable inline copy instead.
  • Never collapse errors into empty states: check isError before rendering empty states, and distinguish unparseable/dropped records from genuinely empty responses.
  • Multi-query views: consolidate errors into a single AlertError rather than sprawling multiple banners, and hide dependent sub-sections whose prerequisite query failed.

ErrorMatcher (classified errors)

Reach for ErrorMatcher when adding dedicated troubleshooting steps for a classified error class (not as a general replacement for AlertError). Pass the full error object from React Query, never error.message:

{
  isError && (
    <ErrorMatcher title="Failed to load tables" error={error} supportFormParams={{ projectRef }} />
  )
}

What NOT to do

  • Do not pass error.message to ErrorMatcher, put regex in error-mappings.tsx, or use Object.assign to stamp _tag (add a tagged class + pattern in data/error-patterns.ts).
  • Do not pass a raw support URL (use supportFormParams={{ projectRef }}), put page titles inside error mappings, or add callback props (onDebugWithAI, onRestartProject) to troubleshooting components (use hooks inside them).
  • Do not assume caught unknown rejections are Error instances (external/WASM libraries can reject with non-Errors) — use getErrorMessage from @/lib/get-error-message.
  • Handle an error's user-facing side effect (toast or inline alert) in a single layer — do not toast and also rethrow to a caller that surfaces errors (or leave an unhandled rejection).

supabase की और Skills

ask-the-docs
supabase
प्रलेखित आर्किटेक्चर, बिल्ड पाइपलाइन और समीक्षा-पैटर्न नोट्स का उपयोग करके Supabase docs ऐप (apps/docs) के बारे में प्रश्नों के उत्तर दें, और फीचर-डिज़ाइन लागू करें…
clickhouse-logs-queries
supabase
Write, review, and migrate Supabase logs queries against the ClickHouse-backed `logs` table (the `logs.all.otel` analytics endpoint). Use this whenever a task…
copywriting
supabase
मोनोरिपो में कहीं भी UI कॉपी (बटन, लेबल, खाली स्थितियाँ, त्रुटि संदेश, टूलटिप्स, फ़ॉर्म टेक्स्ट) लिखें या उसकी समीक्षा करें। शिपिंग या समीक्षा से पहले इसे लोड करें…
dev-toolbar-review
supabase
उन PRs की समीक्षा करते समय उपयोग करें जो packages/dev-tools/, packages/common/posthog-client.ts को छूते हैं,
docs-content
supabase
apps/docs में कहीं भी Supabase सामग्री लिखें, संपादित करें, व्यवस्थित करें और समीक्षा करें — गाइड, व्याख्याकार, ट्यूटोरियल, समस्या निवारण प्रविष्टियाँ, संदर्भ दस्तावेज़, और…
e2e-studio-tests
supabase
स्टूडियो ऐप में e2e परीक्षण चलाएँ। जब e2e परीक्षण चलाने, स्टूडियो परीक्षण चलाने, प्लेराइट परीक्षण चलाने, या फीचर का परीक्षण करने के लिए कहा जाए तो इसका उपयोग करें।
pm-the-docs
supabase
Docs-PM "Write the docs" लेखन प्रक्रिया के लिए निर्णय समर्थन — Frame और Shape चरणों के दौरान दर्शकों, चरण और क्रॉस-कटिंग दायरे के निर्णय लेता है,…
react-hook-form
supabase
React Hook Form का सही उपयोग monorepo में कहीं भी — डेटा फ्लो, सब्सक्रिप्शन, रीसेट, डर्टी स्टेट, नंबर इनपुट, और कंट्रोल्ड इनपुट नियम। इसे लोड करें…