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의 다른 스킬

ask-the-docs
supabase
Supabase 문서 앱(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
PR을 검토할 때 사용하세요. packages/dev-tools/, packages/common/posthog-client.ts 파일을 다루는 경우에 해당합니다.
docs-content
supabase
Supabase 콘텐츠를 apps/docs 어디에서든 작성, 편집, 구성, 검토하세요 — 가이드, 설명 자료, 튜토리얼, 문제 해결 항목, 참조 문서 등…
e2e-studio-tests
supabase
Studio 앱에서 e2e 테스트를 실행합니다. e2e 테스트 실행, 스튜디오 테스트 실행, Playwright 테스트 실행, 또는 기능 테스트를 요청받았을 때 사용하세요.
pm-the-docs
supabase
Docs-PM 의사결정 지원 도구로, "Write the docs" 작성 프로세스에서 Frame 및 Shape 단계 중 대상 독자, 단계, 교차 범위 결정을 지원합니다…
react-hook-form
supabase
모노레포 어디서든 올바른 React Hook Form 사용법 — 데이터 흐름, 구독, 리셋, 더티 상태, 숫자 입력, 제어 입력 규칙. 이것을 로드하세요…