{"record":{"id":"bc817bd034ca36de","repo":"larksuite/cli","slug":"number-expects-a-numeric-value-got-s","errorCode":null,"errorMessage":"number expects a numeric value, got %s","messagePattern":"number expects a numeric value, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/lark_sheet_table_io.go","lineNumber":692,"sourceCode":"\tif nf != \"\" {\n\t\tcell[\"cell_styles\"] = map[string]interface{}{\"number_format\": nf}\n\t}\n\tif raw == nil {\n\t\treturn cell, nil\n\t}\n\tswitch col.Type {\n\tcase \"\":\n\t\t// Type-less column: write the raw JSON scalar as-is so Lark Sheets\n\t\t// auto-detects the type (numeric → number, else text). json.Number is\n\t\t// kept verbatim for precision; an optional --styles number_format\n\t\t// controls display. This is the untyped --values behavior.\n\t\tcell[\"value\"] = raw\n\tcase \"string\":\n\t\tcell[\"value\"] = stringifyCellValue(raw)\n\tcase \"number\":\n\t\tn, ok := raw.(json.Number)\n\t\tif !ok {\n\t\t\treturn 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\n\t\t}\n\t\tcell[\"value\"] = n\n\tcase \"bool\":\n\t\tb, ok := raw.(bool)\n\t\tif !ok {\n\t\t\treturn 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\n\t\t}\n\t\tcell[\"value\"] = b\n\tcase \"date\":\n\t\tstr, ok := raw.(string)\n\t\tif !ok {\n\t\t\treturn 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\n\t\t}\n\t\tserial, err := isoDateToSerial(str)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tcell[\"value\"] = serial","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/lark_sheet_table_io.go#L674-L710","documentation":"buildTypedCell enforces the dtype declared for each column in --sheets/--values payloads. A column declared \"number\" must carry a JSON number (json.Number); any other JSON type (string, bool, object, array, null) triggers this error. The caller adds row/column context and wraps it in a typed validation error.","triggerScenarios":"{\"type\":\"number\",\"name\":\"Amount\"} column with value \"42\" (quoted string), true, null, or an object; CSV-to-JSON converters quoting all values.","commonSituations":"Hand-authored JSON quoting numbers by habit; spreadsheet exports that emit everything as strings; null values for empty numeric cells.","solutions":["Remove quotes from the numeric value so it is a real JSON number: 42 not \"42\"","Change the column dtype to \"string\" (or \"object\") if the values are intentionally text","Replace null/empty numeric cells with a number or restructure to avoid empty cells"],"exampleFix":"// before\n{\"name\":\"Amount\",\"type\":\"number\",\"data\":[\"42\"]}\n// after\n{\"name\":\"Amount\",\"type\":\"number\",\"data\":[42]}","handlingStrategy":"validation","validationCode":"function assertNumberColumn(col) {\n  col.data.forEach((v, i) => {\n    if (typeof v !== 'number') throw new Error(`column ${col.name} (number): row ${i} value ${JSON.stringify(v)} is not a JSON number`);\n  });\n}","typeGuard":"function isJSONNumber(v) { return typeof v === 'number' && Number.isFinite(v); }","tryCatchPattern":"try {\n  await run(['lark','sheet','table-put','--sheets',payload]);\n} catch (e) {\n  if (/number expects a numeric value/.test(e.message)) {\n    // de-quote numbers or switch dtype to \"string\" and retry\n  }\n  throw e;\n}","preventionTips":["Never quote numeric values in --sheets/--values payloads","Convert CSV/TSV data with a typed converter, not naive string mapping","Use dtype \"string\" when values may legitimately be text","Replace null with a real number or omit such rows"],"tags":["cli","json","validation","sheets","dtype"],"backgroundTag":"schema-validation-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}