{"record":{"id":"b91e320c74e9884c","repo":"larksuite/cli","slug":"s-must-be-an-integer-got-s","errorCode":null,"errorMessage":"--%s must be an integer, got %s","messagePattern":"--(.+?) must be an integer, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/sheets/flag_view.go","lineNumber":307,"sourceCode":"\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\n// standalone cobra path. Canonical casing and known aliases are rewritten in\n// place; unknown values are rejected before a translator can silently fall\n// back to a different operation.","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/sheets/flag_view.go#L289-L325","documentation":"Raw-type validation error from validateRawTypes: a flag targeting Go `int` received a valid JSON number with a fractional part (e.g. 1.9). Int() would silently truncate it, so the validator rejects non-integers to keep batch and standalone cobra behavior identical. The intermediate error is wrapped into a typed operations validation error by the batch dispatcher.","triggerScenarios":"Passing `--flag 1.9` or any non-integral float for an int-typed field, e.g. a row index of 2.5 from computed or averaged upstream values.","commonSituations":"Deriving indices from division or averages; passing floats because a related field was float64; unit mismatches producing fractional values.","solutions":["Round or truncate the value explicitly upstream and pass an integer literal.","Verify the field type via --print-schema; if a float is actually needed, use the float-typed field.","Fix the upstream computation producing the fractional number."],"exampleFix":"// before\n--row_id 2.5  // non-integer\n// after\n--row_id 2","handlingStrategy":"validation","validationCode":"function assertInteger(v) {\n  if (typeof v !== \"number\" || !Number.isInteger(v)) {\n    throw new Error(`expected integer, got ${v}`);\n  }\n}","typeGuard":"function isJsonInteger(v: unknown): v is number {\n  return typeof v === \"number\" && Number.isFinite(v) && Number.isInteger(v);\n}","tryCatchPattern":"try {\n  runCommand(args);\n} catch (e) {\n  if (/must be an integer/.test(e.message)) {\n    // round or Math.trunc the value and retry\n  }\n}","preventionTips":["Round explicitly upstream rather than relying on truncation.","Use integer math when computing indices and counts.","Confirm field types via --print-schema; use float fields for fractional values."],"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"}