larksuite/cli · error
date expects an ISO yyyy-mm-dd string, got %s
Error message
date expects an ISO yyyy-mm-dd string, got %s
What it means
A column declared "date" must carry an ISO yyyy-mm-dd string because buildTypedCell parses it into an Excel serial for the sheet. A non-string JSON value (number, bool, object, null) fails this type check; the caller adds row/column context and wraps it in a typed validation error.
Source
Thrown at shortcuts/sheets/lark_sheet_table_io.go:704
cell["value"] = raw
case "string":
cell["value"] = stringifyCellValue(raw)
case "number":
n, ok := raw.(json.Number)
if !ok {
return nil, fmt.Errorf("number expects a numeric value, got %s", describeJSONType(raw)) //nolint:forbidigo // intermediate error; callers wrap it into a typed --sheets/--values validation error with row/column context
}
cell["value"] = n
case "bool":
b, ok := raw.(bool)
if !ok {
return nil, fmt.Errorf("bool expects true/false, got %s", describeJSONType(raw)) //nolint:forbidigo // intermediate error; callers wrap it into a typed --sheets/--values validation error with row/column context
}
cell["value"] = b
case "date":
str, ok := raw.(string)
if !ok {
return nil, fmt.Errorf("date expects an ISO yyyy-mm-dd string, got %s", describeJSONType(raw)) //nolint:forbidigo // intermediate error; callers wrap it into a typed --sheets/--values validation error with row/column context
}
serial, err := isoDateToSerial(str)
if err != nil {
return nil, err
}
cell["value"] = serial
default:
return nil, fmt.Errorf("unsupported type %q", col.Type) //nolint:forbidigo // intermediate error; callers wrap it into a typed --sheets/--values validation error with row/column context
}
return cell, nil
}
// stringifyCellValue renders any JSON scalar as the literal text a string
// column should hold. json.Number keeps its exact digits (no scientific
// notation), so IDs / postcodes survive as written.
func stringifyCellValue(raw interface{}) string {
switch v := raw.(type) {
case string:View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Convert values to "yyyy-mm-dd" strings, e.g. "2026-01-31" (ISO datetime strings like 2026-01-31T09:00:00Z are also accepted)
- If values are raw numbers/text, change the column dtype to "number" or "object"
- Replace null/empty cells with real dates or drop those rows
Example fix
// before
{"name":"Due","type":"date","data":[1738368000]}
// after
{"name":"Due","type":"date","data":["2026-01-31"]} Defensive patterns
Strategy: validation
Validate before calling
function assertDateColumn(col) {
col.data.forEach((v, i) => {
if (typeof v !== 'string' || !/^\d{4}-\d{2}-\d{2}(T[0-9:.+Z-]+)?$/.test(v))
throw new Error(`column ${col.name} (date): row ${i} value ${JSON.stringify(v)} is not an ISO date string`);
});
} Type guard
function isISODateString(v) { return typeof v === 'string' && /^\d{4}-\d{2}-\d{2}(T[0-9:.+Z-]+)?$/.test(v); } Try / catch
try {
await run(['lark','sheet','table-put','--sheets',payload]);
} catch (e) {
if (/date expects an ISO yyyy-mm-dd string/.test(e.message)) {
// convert epoch numbers/Date objects to 'yyyy-mm-dd' strings and retry
}
throw e;
} Prevention
- Normalize all dates to 'yyyy-mm-dd' strings before building the payload
- Convert epoch millis / JS Date objects with toISOString().slice(0,10)
- Use dtype "object" for non-ISO date-like text
When it happens
Trigger: Date column given epoch numbers, JSON null for empty cells, or already-serialized date objects instead of "2026-01-31" strings.
Common situations: Feeding JS Date or epoch millis directly into the payload; null gaps in a date column; converters emitting numbers for dates.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- number expects a numeric value, got %s
- bool expects true/false, got %s
- date column has an empty cell — drop the empty rows, fill re
- %s must be a boolean
- %s must be an integer
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/972f76e534bd7e32.
Report an issue: GitHub.