{"record":{"id":"f2fa41da9f0757b8","repo":"supabase/supabase","slug":"projectref-is-required-f2fa41","errorCode":null,"errorMessage":"projectRef is required","messagePattern":"projectRef is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/studio/data/config/project-storage-config-query.ts","lineNumber":20,"sourceCode":"\nimport { configKeys } from './keys'\nimport { components } from '@/data/api'\nimport { get, handleError } from '@/data/fetchers'\nimport { useDeploymentMode } from '@/hooks/misc/useDeploymentMode'\nimport { IS_PLATFORM } from '@/lib/constants'\nimport type { ResponseError, UseCustomQueryOptions } from '@/types'\n\nexport type ProjectStorageConfigVariables = {\n  projectRef?: string\n}\n\nexport type ProjectStorageConfigResponse = components['schemas']['StorageConfigResponse']\n\nexport async function getProjectStorageConfig(\n  { projectRef }: ProjectStorageConfigVariables,\n  signal?: AbortSignal\n) {\n  if (!projectRef) throw new Error('projectRef is required')\n\n  const { data, error } = await get('/platform/projects/{ref}/config/storage', {\n    params: { path: { ref: projectRef } },\n    signal,\n  })\n\n  if (error) {\n    // [Joshen] This is due to API not returning an error message on this endpoint if a 404 is returned\n    // Should only be a temporary patch, needs to be addressed on the API end\n    if ((error as any).code === 404) {\n      handleError({ ...(error as any), message: 'Storage configuration not found.' })\n    } else {\n      handleError(error)\n    }\n  }\n  return data\n}\n","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/supabase/supabase/blob/beee91b9c2228dd57302dec75c733baaa84ab543/apps/studio/data/config/project-storage-config-query.ts#L2-L38","documentation":"Thrown by getProjectStorageConfig (apps/studio/data/config/project-storage-config-query.ts:20) before GET /platform/projects/{ref}/config/storage. Beyond the standard missing-ref guard, this fetcher also patches a known API gap: a 404 with no message is rewritten to 'Storage configuration not found.' before handleError. The ref guard fires first, so the 404 patch only runs once a ref is present.","triggerScenarios":"Opening the Storage config settings before projectRef resolves, or on a project whose storage backend has not been provisioned (which then surfaces the 404 message, not this guard).","commonSituations":"Newly created project where storage config is not yet available, or a settings tab mounted during project bootstrap before the ref is set.","solutions":["Gate the hook with enabled: typeof projectRef === 'string'.","Handle the downstream 404 ('Storage configuration not found.') as an empty state rather than an error, since it often means 'not provisioned yet'.","For direct calls, early-return when projectRef is falsy."],"exampleFix":"// before\nconst { data } = await getProjectStorageConfig({ projectRef })\n\n// after\nif (!projectRef) return null\nconst { data } = await getProjectStorageConfig({ projectRef })","handlingStrategy":"validation","validationCode":"if (!projectRef) return null\nawait getProjectStorageConfig({ 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 getProjectStorageConfig(vars)\n} catch (e) {\n  // a 404 here means storage not provisioned yet — treat as empty state\n  return null\n}","preventionTips":["Gate the hook on typeof projectRef === 'string'.","Treat the 'Storage configuration not found.' 404 as an empty/provisioning state.","Re-query after storage provisioning completes rather than on a tight interval."],"tags":["validation","precondition","project-ref","react-query","storage-config","studio"],"backgroundTag":null,"analyzedSha":"beee91b9c2228dd57302dec75c733baaa84ab543","analyzedAt":"2026-08-12T06:51:48.935Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}