{"record":{"id":"4db8816ef97b8de2","repo":"larksuite/cli","slug":"s-must-be-a-number-got-s","errorCode":null,"errorMessage":"--%s must be a number, got %s","messagePattern":"--(.+?) must be a number, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_view.go","lineNumber":304,"sourceCode":"\tfor rawKey, val := range m.raw {\n\t\tname := rawKey\n\t\ttyp, ok := declaredType[name]\n\t\tif !ok {\n\t\t\t// flag-defs use hyphen names; tolerate the underscore form users send.\n\t\t\tname = strings.ReplaceAll(rawKey, \"_\", \"-\")\n\t\t\ttyp, ok = declaredType[name]\n\t\t}\n\t\tif !ok {\n\t\t\tcontinue // unknown key — leave it for the translator / schema layer\n\t\t}\n\t\tswitch typ {\n\t\tcase \"int\":\n\t\t\t// Int(): float64 → int(t) truncates, so a non-integer number would\n\t\t\t// be silently floored (1.9 → 1). Standalone cobra rejects it at\n\t\t\t// parse time; reject here too to keep batch/standalone parity.\n\t\t\tf, isNum := val.(float64)\n\t\t\tif !isNum {\n\t\t\t\treturn fmt.Errorf(\"--%s must be a number, got %s\", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error\n\t\t\t}\n\t\t\tif math.Trunc(f) != f {\n\t\t\t\treturn fmt.Errorf(\"--%s must be an integer, got %s\", name, strconv.FormatFloat(f, 'g', -1, 64)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error\n\t\t\t}\n\t\tcase \"float64\":\n\t\t\tif _, isNum := val.(float64); !isNum {\n\t\t\t\treturn fmt.Errorf(\"--%s must be a number, got %s\", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error\n\t\t\t}\n\t\tcase \"bool\":\n\t\t\tif _, isBool := val.(bool); !isBool {\n\t\t\t\treturn fmt.Errorf(\"--%s must be a boolean, got %s\", name, jsonTypeName(val)) //nolint:forbidigo // intermediate error; the batch dispatcher wraps it into a typed operations validation error\n\t\t\t}\n\t\t}\n\t}\n\treturn nil\n}\n\n// normalizeAndValidateEnums applies the same flat string-enum contract as the","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_view.go#L286-L322","documentation":"Raw-type validation error from validateRawTypes in the sheets batch flag view: a flag whose target Go type is `int` received a JSON value that is not a number (e.g. string, bool, object). This preserves batch/standalone parity with cobra's parse-time rejection. The intermediate error is wrapped into a typed operations validation error by the batch dispatcher.","triggerScenarios":"Passing `--flag '{\"x\": \"5\"}'` or a quoted number / boolean / nested value for a field declared int; JSON-decoded value arrives as something other than float64.","commonSituations":"Quoting numbers inside JSON payloads; environment/config substitution injecting strings; copy-pasting payloads where an id was a string in another API.","solutions":["Remove quotes so the value is a JSON number: 5 instead of \"5\".","Check the expected type via --print-schema or --help for the flag.","Coerce upstream values to numbers before building the JSON payload."],"exampleFix":"// before\n--row '{\"row_id\": \"12\"}'  // string\n// after\n--row '{\"row_id\": 12}'    // number","handlingStrategy":"type-guard","validationCode":"function assertIntLike(obj, key) {\n  const v = obj[key];\n  if (typeof v !== \"number\" || !Number.isInteger(v)) {\n    throw new Error(`${key} must be a JSON number, got ${typeof v}`);\n  }\n}","typeGuard":"function isJsonNumber(v: unknown): v is number {\n  return typeof v === \"number\" && Number.isFinite(v);\n}","tryCatchPattern":"try {\n  runCommand(args);\n} catch (e) {\n  if (/must be a number, got/.test(e.message)) {\n    // inspect jsonTypeName in the message and unquote/fix the JSON value\n  }\n}","preventionTips":["Never quote numeric values inside JSON flag payloads.","Sanitize environment/config substitutions that inject strings.","Check flag types with --help/--print-schema before composing payloads."],"tags":["sheets","type-validation","cli"],"backgroundTag":"invalid-argument-value","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"}