{"record":{"id":"9499744f55ad8cc7","repo":"larksuite/cli","slug":"v-overflows-s","errorCode":null,"errorMessage":"%v overflows %s","messagePattern":"(.+?) overflows (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":243,"sourceCode":"\t\t\t}\n\t\t\tresult.Index(i).Set(reflect.ValueOf(value))\n\t\t}\n\t\tif target.Kind() == reflect.Array {\n\t\t\tarray := reflect.New(target).Elem()\n\t\t\treflect.Copy(array, result)\n\t\t\treturn array.Interface(), nil\n\t\t}\n\t\treturn result.Convert(target).Interface(), nil\n\t}\n\tif rawValue.Type().ConvertibleTo(target) {\n\t\tconverted := reflect.New(target).Elem()\n\t\tif isSignedIntegerKind(rawValue.Kind()) && isUnsignedIntegerKind(target.Kind()) {\n\t\t\tif rawValue.Int() < 0 || converted.OverflowUint(uint64(rawValue.Int())) {\n\t\t\t\treturn nil, fmt.Errorf(\"%v cannot be represented as %s\", raw, target)\n\t\t\t}\n\t\t}\n\t\tif isSignedIntegerKind(rawValue.Kind()) && isSignedIntegerKind(target.Kind()) && converted.OverflowInt(rawValue.Int()) {\n\t\t\treturn nil, fmt.Errorf(\"%v overflows %s\", raw, target)\n\t\t}\n\t\tif isUnsignedIntegerKind(rawValue.Kind()) && isUnsignedIntegerKind(target.Kind()) && converted.OverflowUint(rawValue.Uint()) {\n\t\t\treturn nil, fmt.Errorf(\"%v overflows %s\", raw, target)\n\t\t}\n\t\treturn rawValue.Convert(target).Interface(), nil\n\t}\n\tencoded, err := json.Marshal(raw)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvalue := reflect.New(target)\n\tif err := json.Unmarshal(encoded, value.Interface()); err != nil {\n\t\treturn nil, err\n\t}\n\treturn value.Elem().Interface(), nil\n}\n\nfunc assignCompiledField(root reflect.Value, field compiledInputField, value any, provided bool) error {","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L225-L261","documentation":"This error fires when a signed integer value is converted to a narrower signed integer type that cannot hold it (reflect's OverflowInt returns true). The typed binder refuses to silently truncate the value, since that would produce wrong API request data. It is thrown from convertReflectValue during typed field binding when a caller-supplied value is coerced to the target Go type.","triggerScenarios":"Passing a signed integer (e.g. int64 or int) as a field value whose declared target type is a smaller signed type (int8/int16/int32), where the value exceeds the target range — e.g. value 300 into an int8 field, or 5000000000 into an int32 field.","commonSituations":"Developers bind IDs, timestamps, or byte counts from JSON/config into typed struct fields; a millis timestamp or large snowflake ID (which needs int64) assigned to an int32 field overflows. Also common after switching a struct field from int64 to int without updating callers.","solutions":["Change the target field type to a wider signed integer (int64) that can hold the value.","Clamp or validate the value in the caller before binding so it fits the target type.","If the source value is already the right magnitude, fix the source (e.g. pass milliseconds not nanoseconds)."],"exampleFix":"// before\ntype Req struct {\n    Deadline int32 `json:\"deadline\"`\n}\nreq := Req{Deadline: int32(time.Now().UnixMilli())} // overflows int32\n\n// after\ntype Req struct {\n    Deadline int64 `json:\"deadline\"`\n}\nreq := Req{Deadline: time.Now().UnixMilli()}","handlingStrategy":"validation","validationCode":"func fitsInt32(v int64) bool { return v >= math.MinInt32 && v <= math.MaxInt32 } // adjust bounds to the declared target type before binding","typeGuard":"func asInt32(v any) (int32, bool) { n, ok := v.(int64); if !ok || n < math.MinInt32 || n > math.MaxInt32 { return 0, false }; return int32(n), true }","tryCatchPattern":"if err := binder.Set(\"deadline\", ts); err != nil {\n    if strings.Contains(err.Error(), \"overflows\") {\n        return fmt.Errorf(\"deadline %d too large for field type: %w\", ts, err)\n    }\n    return err\n}","preventionTips":["Default all ID/timestamp/size fields to int64 in bound structs.","Run go vet / overflow linters on struct literals.","Range-check values at system boundaries before handing them to the binder."],"tags":["go","type-binding","integer-overflow","reflection"],"backgroundTag":"integer-overflow","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"}