{"record":{"id":"198369070d14382c","repo":"larksuite/cli","slug":"must-be-a-nonnegative-integer-w","errorCode":null,"errorMessage":"must be a nonnegative integer: %w","messagePattern":"must be a nonnegative integer: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_args.go","lineNumber":562,"sourceCode":"func parseFiniteFloat(value string) (float64, error) {\n\treturn parseFiniteFloatBits(value, 64)\n}\n\nfunc parseFiniteFloatBits(value string, bits int) (float64, error) {\n\tparsed, err := strconv.ParseFloat(value, bits)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif math.IsNaN(parsed) || math.IsInf(parsed, 0) {\n\t\treturn 0, fmt.Errorf(\"must be finite\")\n\t}\n\treturn parsed, nil\n}\n\nfunc parseNonnegativeInt(value string) (int, error) {\n\tparsed, err := strconv.ParseUint(value, 10, 31)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"must be a nonnegative integer: %w\", err)\n\t}\n\treturn int(parsed), nil\n}\n\nfunc indirectType(t reflect.Type) reflect.Type {\n\tfor t.Kind() == reflect.Pointer {\n\t\tt = t.Elem()\n\t}\n\treturn t\n}\nfunc indirectKind(t reflect.Type) reflect.Kind { return indirectType(t).Kind() }\nfunc isIntegerKind(kind reflect.Kind) bool {\n\treturn kind >= reflect.Int && kind <= reflect.Int64 || kind >= reflect.Uint && kind <= reflect.Uint64\n}\nfunc isNilCapable(t reflect.Type) bool {\n\tswitch t.Kind() {\n\tcase reflect.Pointer, reflect.Slice, reflect.Map, reflect.Interface:\n\t\treturn true","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_args.go#L544-L580","documentation":"parseNonnegativeInt parses a value that must be a nonnegative integer (bounded to fit an int) using strconv.ParseUint(value,10,31). Any string that fails uint parsing (negative sign, non-digits, overflow) is wrapped with this message, preserving the underlying ParseUint error via %w.","triggerScenarios":"A schema tag numeric value like minLength, minItems, or maxLength is given as \"-1\", \"abc\", \"\", or a number larger than 2^31-1 (e.g. \"99999999999\").","commonSituations":"Typos in tag values; negative counts intended as 'no limit'; copying large limits from docs exceeding the 31-bit cap.","solutions":["Use a plain nonnegative decimal integer string, e.g. \"0\", \"10\"","To express 'no limit', omit the corresponding bound token instead of using -1","Reduce values above 2147483647 to a within-range number"],"exampleFix":"// before\n`schema:\"minLength=-1\"`\n// after\n`schema:\"minLength=0\"`","handlingStrategy":"validation","validationCode":"func validNonnegativeInt(s string) bool {\n\tif s == \"\" || s[0] == '-' { return false }\n\t_, err := strconv.ParseUint(s, 10, 31)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Express 'no limit' by omitting the bound, not with -1","Keep tag counts within 0..2147483647","Test schema tags with a parser during CI"],"tags":["go","integer","parsing","validation"],"backgroundTag":"invalid-integer-format","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"}