{"record":{"id":"747ee9327f72880d","repo":"Budibase/budibase","slug":"invalid-label-value","errorCode":null,"errorMessage":"Invalid ${label}: ${value}","messagePattern":"Invalid (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/server/src/sdk/workspace/ai/agentLogs/shared.ts","lineNumber":144,"sourceCode":"}\n\nexport function parseDate(value?: string): Date | undefined {\n  if (!value) {\n    return undefined\n  }\n\n  const parsedDate = new Date(value)\n  if (!Number.isFinite(parsedDate.getTime())) {\n    return undefined\n  }\n\n  return parsedDate\n}\n\nexport function parseDateOrThrow(value: string, label: string): string {\n  const parsedDate = parseDate(value)\n  if (!parsedDate) {\n    throw new Error(`Invalid ${label}: ${value}`)\n  }\n  return parsedDate.toISOString()\n}\n\nexport function minDate(a?: string, b?: string): string {\n  const firstDate = parseDate(a)\n  const secondDate = parseDate(b)\n  if (!firstDate && !secondDate) {\n    throw new Error(\n      `Expected at least one valid date, received '${a}' and '${b}'`\n    )\n  }\n  if (!firstDate) return secondDate!.toISOString()\n  if (!secondDate) return firstDate.toISOString()\n\n  return firstDate <= secondDate\n    ? firstDate.toISOString()\n    : secondDate.toISOString()","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/Budibase/budibase/blob/a81a902e9a8fe55b467d106765f6638f12e35c49/packages/server/src/sdk/workspace/ai/agentLogs/shared.ts#L126-L162","documentation":"parseDateOrThrow validates a string date against parseDate and throws 'Invalid ${label}: ${value}' when the value cannot be parsed to a Date. The label parameter names the caller's context (e.g. 'startTime' or 'endTime'), so the message tells you exactly which query parameter was bad.","triggerScenarios":"Calling the agent session/log list endpoints with a startTime/endTime (via fallbackStartTime/fallbackEndTime) that is not ISO-8601 or a parseable date string — e.g. '2024/01/15 10:00', 'yesterday', an epoch in milliseconds as a string, or an empty-ish garbage value.","commonSituations":"Frontend sends localized date formats (dd/mm/yyyy) instead of ISO strings; user-supplied filter values passed straight through; timezone suffixes unsupported by the parser; epoch numbers passed as strings.","solutions":["Send dates as ISO-8601 UTC strings, e.g. 2024-01-15T10:00:00.000Z","Validate dates client-side with new Date(value) and Date.toISOString() before calling the API","Read the label in the error message to identify exactly which parameter is malformed","If passing epoch timestamps, convert to an ISO string first"],"exampleFix":"// before\nconst params = { startTime: \"15/01/2024 10:00\" }\n// after\nconst params = { startTime: new Date(\"2024-01-15T10:00:00Z\").toISOString() }","handlingStrategy":"validation","validationCode":"function isValidDateParam(v: unknown): v is string {\n  return typeof v === \"string\" && !Number.isNaN(Date.parse(v))\n}","typeGuard":"function isISODateString(v: unknown): v is string {\n  return typeof v === \"string\" && /^\\d{4}-\\d{2}-\\d{2}T/.test(v) && !Number.isNaN(Date.parse(v))\n}","tryCatchPattern":"try {\n  const sessions = await listAgentSessions({ startTime, endTime })\n} catch (err) {\n  if ((err as Error).message.startsWith(\"Invalid \")) {\n    throw new HTTPError(\"startTime/endTime must be ISO-8601 dates\", 400)\n  }\n  throw err\n}","preventionTips":["Always send ISO-8601 UTC strings (toISOString())","Validate dates client-side before calling the API","Avoid locale-dependent date formats","Convert epoch numbers to ISO strings first"],"tags":["validation","dates","agent-logs","http-400"],"backgroundTag":"invalid-date-parameter","analyzedSha":"a81a902e9a8fe55b467d106765f6638f12e35c49","analyzedAt":"2026-08-29T01:03:10.972Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}