{"record":{"id":"f54f31946bda6bb0","repo":"supabase/supabase","slug":"projectref-is-required-f54f31","errorCode":null,"errorMessage":"projectRef is required","messagePattern":"projectRef is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/studio/data/config/project-unpause-postgres-versions-query.ts","lineNumber":15,"sourceCode":"import { useQuery } from '@tanstack/react-query'\n\nimport { configKeys } from './keys'\nimport { get, handleError } from '@/data/fetchers'\nimport type { ResponseError, UseCustomQueryOptions } from '@/types'\n\nexport type ProjectUnpausePostgresVersionsVariables = {\n  projectRef?: string\n}\n\nexport async function getPostgresUnpauseVersions(\n  { projectRef }: ProjectUnpausePostgresVersionsVariables,\n  signal?: AbortSignal\n) {\n  if (!projectRef) throw new Error('projectRef is required')\n\n  const { data, error } = await get('/platform/projects/{ref}/restore/versions', {\n    params: { path: { ref: projectRef } },\n    signal,\n  })\n\n  if (error) handleError(error)\n  return data\n}\n\nexport type ProjectUnpausePostgresVersionData = Awaited<\n  ReturnType<typeof getPostgresUnpauseVersions>\n>\nexport type ProjectUnpausePostgresVersionError = ResponseError\n\nexport const useProjectUnpausePostgresVersionsQuery = <TData = ProjectUnpausePostgresVersionData>(\n  { projectRef }: ProjectUnpausePostgresVersionsVariables,\n  {","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/supabase/supabase/blob/beee91b9c2228dd57302dec75c733baaa84ab543/apps/studio/data/config/project-unpause-postgres-versions-query.ts#L1-L33","documentation":"Thrown by getPostgresUnpauseVersions (apps/studio/data/config/project-unpause-postgres-versions-query.ts:15) before GET /platform/projects/{ref}/restore/versions. This query runs specifically during the unpause/restore flow, so it must have a target project ref; the guard blocks fetching restore versions for a non-existent project.","triggerScenarios":"Opening the restore/unpause dialog before projectRef is bound, or calling the fetcher outside the restore flow.","commonSituations":"Restore flow triggered on a paused project whose ref has not yet been committed to the store, or a dialog mounted on a route that lost the project param.","solutions":["Gate the hook with enabled: typeof projectRef === 'string'.","Only mount the restore-versions selector once the project is identified.","For direct calls, early-return on a falsy ref."],"exampleFix":"// before\nconst { data } = await getPostgresUnpauseVersions({ projectRef })\n\n// after\nif (!projectRef) return null\nconst { data } = await getPostgresUnpauseVersions({ projectRef })","handlingStrategy":"validation","validationCode":"if (!projectRef) return null\nawait getPostgresUnpauseVersions({ projectRef })","typeGuard":"const hasProjectRef = (\n  v: { projectRef?: string }\n): v is { projectRef: string } => typeof v.projectRef === 'string' && v.projectRef.length > 0","tryCatchPattern":"if (!hasProjectRef(vars)) return null\ntry {\n  return await getPostgresUnpauseVersions(vars)\n} catch (e) {\n  return null\n}","preventionTips":["Mount the restore-versions selector only once the target project is known.","Gate the hook on typeof projectRef === 'string'.","Clear the selector state when the project changes."],"tags":["validation","precondition","project-ref","react-query","unpause","restore","studio"],"backgroundTag":null,"analyzedSha":"beee91b9c2228dd57302dec75c733baaa84ab543","analyzedAt":"2026-08-12T06:51:48.935Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}