{"record":{"id":"d2c2d552ea3ffb4d","repo":"supabase/supabase","slug":"start-date-is-required","errorCode":null,"errorMessage":"Start date is required","messagePattern":"Start date is required","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/studio/data/analytics/infra-monitoring-query.ts","lineNumber":66,"sourceCode":"  endDate?: string\n  interval?: InfraMonitoringInterval\n  databaseIdentifier?: string\n}\n\nexport async function getInfraMonitoringAttributes(\n  {\n    projectRef,\n    attributes,\n    startDate,\n    endDate,\n    interval = '1h',\n    databaseIdentifier,\n  }: InfraMonitoringMultiVariables,\n  signal?: AbortSignal\n) {\n  if (!projectRef) throw new Error('Project ref is required')\n  if (!attributes?.length) throw new Error('At least one attribute is required')\n  if (!startDate) throw new Error('Start date is required')\n  if (!endDate) throw new Error('End date is required')\n\n  // Backend doesn't support 2m granularity, so request 1m and aggregate in frontend\n  const is2MinInterval = interval === '2m'\n  const requestInterval: AnalyticsInterval = is2MinInterval ? '1m' : (interval as AnalyticsInterval)\n\n  const { data, error } = await get('/platform/projects/{ref}/infra-monitoring', {\n    params: {\n      path: { ref: projectRef },\n      // Attributes support is not yet reflected in the generated client types.\n      query: {\n        attributes,\n        startDate,\n        endDate,\n        interval: requestInterval,\n        databaseIdentifier,\n      } as any,\n    },","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/supabase/supabase/blob/beee91b9c2228dd57302dec75c733baaa84ab543/apps/studio/data/analytics/infra-monitoring-query.ts#L48-L84","documentation":"Third guard in getInfraMonitoringAttributes: throws 'Start date is required' when startDate is falsy. The endpoint needs a time window; without a lower bound the query is rejected client-side.","triggerScenarios":"Time-range picker not initialized; user cleared the start date; relative-range helper returned undefined for startDate; SSR before the default window is computed.","commonSituations":"Date picker defaults applied via useEffect after first render; deep-link without a start param; clock/timezone utils returning undefined for an edge-case input.","solutions":["Compute a default startDate (e.g. now - 24h) synchronously at the call site, not in an effect.","Gate with `enabled: !!startDate`.","Validate startDate parses to a valid ISO string before submitting."],"exampleFix":"// before\nuseInfraMonitoringQuery({ projectRef, attributes, startDate, endDate })\n\n// after\nconst defaultStart = useMemo(() => dayjs().subtract(24, 'hour').toISOString(), [])\nuseInfraMonitoringQuery(\n  { projectRef, attributes, startDate: startDate ?? defaultStart, endDate },\n  { enabled: !!(projectRef && attributes?.length && endDate) }\n)","handlingStrategy":"validation","validationCode":"// Compute default window synchronously, not in an effect.\nconst startDate = useMemo(() => dayjs().subtract(24, 'hour').toISOString(), [])\nconst endDate = useMemo(() => dayjs().toISOString(), [])\nuseQuery({\n  queryKey: ['infra-monitoring', projectRef, attributes, startDate, endDate],\n  queryFn: ({ signal }) =>\n    getInfraMonitoringAttributes({ projectRef, attributes, startDate, endDate }, signal),\n  enabled: !!(projectRef && attributes?.length),\n})","typeGuard":"function isIsoDate(v: unknown): v is string {\n  return typeof v === 'string' && Number.isFinite(Date.parse(v))\n}","tryCatchPattern":"try {\n  const attrs = await getInfraMonitoringAttributes({ projectRef, attributes, startDate, endDate })\n} catch (e) {\n  if (e instanceof Error && e.message === 'Start date is required') return\n  throw e\n}","preventionTips":["Compute date defaults synchronously at the call site, not via useEffect.","Validate startDate parses before submitting.","Gate the query on startDate presence."],"tags":["validation","analytics","params","infra-monitoring","dates"],"backgroundTag":null,"analyzedSha":"beee91b9c2228dd57302dec75c733baaa84ab543","analyzedAt":"2026-08-12T06:51:48.935Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}