Budibase/budibase · error

Invalid ${label}: ${value}

Error message

Invalid ${label}: ${value}

What it means

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.

Source

Thrown at packages/server/src/sdk/workspace/ai/agentLogs/shared.ts:144

}

export function parseDate(value?: string): Date | undefined {
  if (!value) {
    return undefined
  }

  const parsedDate = new Date(value)
  if (!Number.isFinite(parsedDate.getTime())) {
    return undefined
  }

  return parsedDate
}

export function parseDateOrThrow(value: string, label: string): string {
  const parsedDate = parseDate(value)
  if (!parsedDate) {
    throw new Error(`Invalid ${label}: ${value}`)
  }
  return parsedDate.toISOString()
}

export function minDate(a?: string, b?: string): string {
  const firstDate = parseDate(a)
  const secondDate = parseDate(b)
  if (!firstDate && !secondDate) {
    throw new Error(
      `Expected at least one valid date, received '${a}' and '${b}'`
    )
  }
  if (!firstDate) return secondDate!.toISOString()
  if (!secondDate) return firstDate.toISOString()

  return firstDate <= secondDate
    ? firstDate.toISOString()
    : secondDate.toISOString()

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Send dates as ISO-8601 UTC strings, e.g. 2024-01-15T10:00:00.000Z
  2. Validate dates client-side with new Date(value) and Date.toISOString() before calling the API
  3. Read the label in the error message to identify exactly which parameter is malformed
  4. If passing epoch timestamps, convert to an ISO string first

Example fix

// before
const params = { startTime: "15/01/2024 10:00" }
// after
const params = { startTime: new Date("2024-01-15T10:00:00Z").toISOString() }
Defensive patterns

Strategy: validation

Validate before calling

function isValidDateParam(v: unknown): v is string {
  return typeof v === "string" && !Number.isNaN(Date.parse(v))
}

Type guard

function isISODateString(v: unknown): v is string {
  return typeof v === "string" && /^\d{4}-\d{2}-\d{2}T/.test(v) && !Number.isNaN(Date.parse(v))
}

Try / catch

try {
  const sessions = await listAgentSessions({ startTime, endTime })
} catch (err) {
  if ((err as Error).message.startsWith("Invalid ")) {
    throw new HTTPError("startTime/endTime must be ISO-8601 dates", 400)
  }
  throw err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/747ee9327f72880d. Report an issue: GitHub.