supabase/supabase · error · Error
projectRef is required
Error message
projectRef is required
What it means
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.
Source
Thrown at apps/studio/data/config/project-unpause-postgres-versions-query.ts:15
import { useQuery } from '@tanstack/react-query'
import { configKeys } from './keys'
import { get, handleError } from '@/data/fetchers'
import type { ResponseError, UseCustomQueryOptions } from '@/types'
export type ProjectUnpausePostgresVersionsVariables = {
projectRef?: string
}
export async function getPostgresUnpauseVersions(
{ projectRef }: ProjectUnpausePostgresVersionsVariables,
signal?: AbortSignal
) {
if (!projectRef) throw new Error('projectRef is required')
const { data, error } = await get('/platform/projects/{ref}/restore/versions', {
params: { path: { ref: projectRef } },
signal,
})
if (error) handleError(error)
return data
}
export type ProjectUnpausePostgresVersionData = Awaited<
ReturnType<typeof getPostgresUnpauseVersions>
>
export type ProjectUnpausePostgresVersionError = ResponseError
export const useProjectUnpausePostgresVersionsQuery = <TData = ProjectUnpausePostgresVersionData>(
{ projectRef }: ProjectUnpausePostgresVersionsVariables,
{View on GitHub (pinned to beee91b9c2)
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.
Example fix
// before
const { data } = await getPostgresUnpauseVersions({ projectRef })
// after
if (!projectRef) return null
const { data } = await getPostgresUnpauseVersions({ projectRef }) Defensive patterns
Strategy: validation
Validate before calling
if (!projectRef) return null
await getPostgresUnpauseVersions({ projectRef }) Type guard
const hasProjectRef = (
v: { projectRef?: string }
): v is { projectRef: string } => typeof v.projectRef === 'string' && v.projectRef.length > 0 Try / catch
if (!hasProjectRef(vars)) return null
try {
return await getPostgresUnpauseVersions(vars)
} catch (e) {
return null
} Prevention
- 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.
When it happens
Trigger: Opening the restore/unpause dialog before projectRef is bound, or calling the fetcher outside the restore flow.
Common situations: 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.
Related errors
- Project ref is required
- projectRef is required
- Project ref is required
- projectRef is required
- projectRef is required
AI-assisted analysis of supabase/supabase@beee91b9c2 (2026-08-12).
Data as JSON: /api/errors/f54f31946bda6bb0.
Report an issue: GitHub.