Budibase/budibase · error · HTTPError

Invalid format for field "${columnName}": "${columnData}". D

Error message

Invalid format for field "${columnName}": "${columnData}". Datetime fields must be in ISO format, e.g. "YYYY-MM-DDTHH:MM:SSZ".

What it means

An HTTP 400 thrown in packages/server/src/utilities/schema.ts when a value for a regular DATETIME column (no ignoreTimezones, not dateOnly at the point of message building) cannot be parsed into a valid date. The library requires ISO 8601 strings like "YYYY-MM-DDTHH:MM:SSZ"; for dateOnly columns the message instead suggests "YYYY-MM-DD". It guards against non-ISO strings that Date() would silently accept with unintended interpretations.

Source

Thrown at packages/server/src/utilities/schema.ts:196

      } else if (columnType === FieldType.DATETIME) {
        if (columnData && !columnSchema.timeOnly) {
          if (columnSchema.ignoreTimezones) {
            if (!sql.utils.isValidISODateStringWithoutTimezone(columnData)) {
              throw new HTTPError(
                `Invalid format for field "${columnName}": "${columnData}". Datetime fields with ignoreTimezones must be in ISO format, e.g. "YYYY-MM-DDTHH:MM:SS".`,
                400
              )
            }
            parsedRow[columnName] = new Date(columnData.trim() + "Z")
          } else {
            if (!sql.utils.isValidISODateString(columnData)) {
              let message = `Invalid format for field "${columnName}": "${columnData}".`
              if (columnSchema.dateOnly) {
                message += ` Date-only fields must be in the format "YYYY-MM-DD".`
              } else {
                message += ` Datetime fields must be in ISO format, e.g. "YYYY-MM-DDTHH:MM:SSZ".`
              }
              throw new HTTPError(message, 400)
            }
          }
        }
        if (columnData && columnSchema.timeOnly) {
          if (!sql.utils.isValidTime(columnData)) {
            throw new HTTPError(
              `Invalid format for field "${columnName}": "${columnData}". Time-only fields must be in the format "HH:MM:SS".`,
              400
            )
          }
        }
        parsedRow[columnName] = columnData
      } else if (
        columnType === FieldType.JSON &&
        typeof columnData === "string"
      ) {
        parsedRow[columnName] = parseJsonExport(columnData)
      } else if (columnType === FieldType.BB_REFERENCE) {

View on GitHub (pinned to a81a902e9a)

Solutions

  1. Convert the value to full ISO 8601 UTC with a Z suffix, e.g. new Date(x).toISOString().
  2. For dateOnly columns, send exactly "YYYY-MM-DD".
  3. Fix the source CSV/spreadsheet column format to ISO before import.
  4. Ensure the value is a string, not a number/Date object, before posting.

Example fix

// before
row["created"] = "01/05/2024"
// after
row["created"] = new Date("2024-01-05T00:00:00Z").toISOString() // "2024-01-05T00:00:00.000Z"
Defensive patterns

Strategy: validation

Validate before calling

function toIso(value: unknown): string {
  const d = value instanceof Date ? value : new Date(String(value))
  if (isNaN(d.getTime())) throw new Error(`Not a date: ${String(value)}`)
  return d.toISOString()
}
row.created = toIso(rawInput)

Type guard

function isIsoDateTime(v: unknown): v is string {
  return typeof v === "string" && !isNaN(new Date(v).getTime()) &&
    /^\d{4}-\d{2}-\d{2}(T[\d:.]+Z?)?$/.test(v.trim())
}

Try / catch

try {
  await saveRow(row)
} catch (e) {
  if (e instanceof HTTPError && e.status === 400 && /must be in ISO format/.test(e.message)) {
    row.created = new Date(row.created).toISOString()
    await saveRow(row)
  } else throw e
}

Prevention

When it happens

Trigger: Posting rows or importing CSV where a datetime column gets a US-format string ("01/05/2024"), a locale string ("5 Jan 2024"), a timestamp number, or a malformed ISO value that fails the parser, for a column without ignoreTimezones.

Common situations: CSV imports from spreadsheets that format dates as MM/DD/YYYY; REST integrations sending epoch millis as numbers coerced to strings; dateOnly columns receiving full timestamps (message variant); regional date formats from browser pickers pasted in.

Related errors


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