{"record":{"id":"3acde85d9a0449c0","repo":"larksuite/cli","slug":"s-must-be-an-integer","errorCode":null,"errorMessage":"%s must be an integer","messagePattern":"(.+?) must be an integer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":441,"sourceCode":"\t\t\treturn fmt.Errorf(\"%s must contain at most %d characters\", path, *constraint.MaxLength)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, text) {\n\t\t\treturn fmt.Errorf(\"%s must be one of: %s\", path, strings.Join(constraint.Enum, \", \"))\n\t\t}\n\t\treturn nil\n\tcase typedBooleanShape:\n\t\tboolean, ok := value.(bool)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a boolean\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, boolean) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported boolean value\", path)\n\t\t}\n\t\treturn nil\n\tcase typedIntegerShape:\n\t\tnumber, ok := validationInteger(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be an integer\", path)\n\t\t}\n\t\tif constraint.Minimum != nil && number < *constraint.Minimum {\n\t\t\treturn fmt.Errorf(\"%s must be at least %d\", path, *constraint.Minimum)\n\t\t}\n\t\tif constraint.Maximum != nil && number > *constraint.Maximum {\n\t\t\treturn fmt.Errorf(\"%s must be at most %d\", path, *constraint.Maximum)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported integer value\", path)\n\t\t}\n\t\treturn nil\n\tcase typedNumberShape:\n\t\tnumber, ok := validationNumber(value)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"%s must be a number\", path)\n\t\t}\n\t\tif len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {\n\t\t\treturn fmt.Errorf(\"%s has an unsupported number value\", path)","sourceCodeStart":423,"sourceCodeEnd":459,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L423-L459","documentation":"A field typed as integer received a JSON number that is not an integer — typically a float like 3.5, or a JSON number decoded as float64 without integral value. validationInteger(value) rejects it before constraint checks. Note: an integral float such as 3.0 may also be rejected depending on validationInteger, since JSON decoding yields float64.","triggerScenarios":"Passing 1.5 to an integer field; supplying a computed value like size/2 that yields a fractional number; passing a numeric string \"42\" (not a number at all) validated through validateCompiledValue.","commonSituations":"Doing arithmetic in shell/scripts that produces decimals; copying float values from other APIs (page sizes, durations in seconds); YAML/JSON configs where IDs were quoted or written with decimals.","solutions":["Round or floor the value to a whole number before passing it","If the source is a string, convert it to an integer (and keep it unquoted in JSON)","Check `schema` for the field's type; use the number-typed field if fractions are intended","Beware float64 artifacts: compute with integers where possible"],"exampleFix":"// before\nsize := total / 2 // 2.5 on odd totals\n// after\nsize := total / 2\nif total%2 != 0 { size = (total+1)/2 } // keep it integral\n// or: size := int(math.Ceil(float64(total)/2))","handlingStrategy":"validation","validationCode":"func ensureIntegral(v any) error {\n    switch n := v.(type) {\n    case int, int64:\n        return nil\n    case float64:\n        if n != math.Trunc(n) {\n            return fmt.Errorf(\"%v is not an integer\", n)\n        }\n        return nil\n    default:\n        return fmt.Errorf(\"expected integer, got %T\", v)\n    }\n}","typeGuard":"func isIntegral(v any) bool {\n    n, ok := v.(float64)\n    return ok && n == math.Trunc(n)\n}","tryCatchPattern":"if err := bind(field, v); err != nil {\n    if strings.Contains(err.Error(), \"must be an integer\") {\n        return fmt.Errorf(\"field %s needs a whole number; got %v: %w\", field, v, err)\n    }\n    return err\n}","preventionTips":["Use int/int64 Go fields for integer-typed schema fields","Round or ceil computed values explicitly before binding","Keep numbers unquoted in JSON and convert string sources with strconv.Atoi","Beware float division producing fractions; use integer math where possible"],"tags":["validation","cli","json","integer","type-mismatch"],"backgroundTag":"schema-type-mismatch","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"}