{"record":{"id":"a13bf4a1a47ca1b1","repo":"larksuite/cli","slug":"v-cannot-be-represented-as-s","errorCode":null,"errorMessage":"%v cannot be represented as %s","messagePattern":"(.+?) cannot be represented as (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_binder.go","lineNumber":239,"sourceCode":"\t\tfor i := 0; i < rawValue.Len(); i++ {\n\t\t\tvalue, err := convertReflectValue(rawValue.Index(i).Interface(), target.Elem())\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\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}","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_binder.go#L221-L257","documentation":"During integer conversion, a signed source value that is negative or exceeds the destination unsigned type's range cannot be represented; convertReflectValue rejects it with '%v cannot be represented as %s' instead of silently wrapping around.","triggerScenarios":"Passing a negative number to a uint-typed field, or a value above the unsigned max of the target width (e.g. 300 into uint8, -1 into uint64).","commonSituations":"IDs or sizes copied as signed values including sentinels like -1 ('unlimited'); JSON numbers exceeding narrow Go integer widths; type narrowing after schema change.","solutions":["Replace negative values with the API's accepted non-negative equivalent (omit the field or use the documented sentinel)","Clamp values to the target's max (e.g. 255 for uint8) or widen the field type in the shortcut definition","Verify with schema output which integer width the field declares"],"exampleFix":"// before\n--limit -1  // into uint32\n// after\n--limit 4294967295  // or omit if the API treats absence as unlimited","handlingStrategy":"validation","validationCode":"const n = Number(raw); if (!Number.isInteger(n) || n < 0 || n > 4294967295) throw new Error('out of uint32 range')","typeGuard":"func fitsUint(v int64, bits int) bool { return v >= 0 && v <= int64(uint64(1)<<uint(bits)-1) }","tryCatchPattern":"if strings.Contains(err.Error(), \"cannot be represented as\") { /* replace negative sentinel or clamp to the type max */ }","preventionTips":["Never pass -1 as an ID/limit to unsigned fields; omit or use documented sentinels","Check the declared integer width via schema output","Clamp or validate numeric inputs at script boundaries"],"tags":["type-conversion","integer-overflow","input-binding"],"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"}