larksuite/cli · error
must be a nonnegative integer: %w
Error message
must be a nonnegative integer: %w
What it means
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.
Source
Thrown at shortcuts/common/typed_compile_args.go:562
func parseFiniteFloat(value string) (float64, error) {
return parseFiniteFloatBits(value, 64)
}
func parseFiniteFloatBits(value string, bits int) (float64, error) {
parsed, err := strconv.ParseFloat(value, bits)
if err != nil {
return 0, err
}
if math.IsNaN(parsed) || math.IsInf(parsed, 0) {
return 0, fmt.Errorf("must be finite")
}
return parsed, nil
}
func parseNonnegativeInt(value string) (int, error) {
parsed, err := strconv.ParseUint(value, 10, 31)
if err != nil {
return 0, fmt.Errorf("must be a nonnegative integer: %w", err)
}
return int(parsed), nil
}
func indirectType(t reflect.Type) reflect.Type {
for t.Kind() == reflect.Pointer {
t = t.Elem()
}
return t
}
func indirectKind(t reflect.Type) reflect.Kind { return indirectType(t).Kind() }
func isIntegerKind(kind reflect.Kind) bool {
return kind >= reflect.Int && kind <= reflect.Int64 || kind >= reflect.Uint && kind <= reflect.Uint64
}
func isNilCapable(t reflect.Type) bool {
switch t.Kind() {
case reflect.Pointer, reflect.Slice, reflect.Map, reflect.Interface:
return trueView on GitHub (pinned to 7fd6ef3c07)
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
Example fix
// before `schema:"minLength=-1"` // after `schema:"minLength=0"`
Defensive patterns
Strategy: validation
Validate before calling
func validNonnegativeInt(s string) bool {
if s == "" || s[0] == '-' { return false }
_, err := strconv.ParseUint(s, 10, 31)
return err == nil
} Prevention
- Express 'no limit' by omitting the bound, not with -1
- Keep tag counts within 0..2147483647
- Test schema tags with a parser during CI
When it happens
Trigger: 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").
Common situations: Typos in tag values; negative counts intended as 'no limit'; copying large limits from docs exceeding the 31-bit cap.
Related errors
- Invalid column: {column!r}
- Invalid column index: {index}
- anchor outside sheet: {position!r}
- Missing row_count/column_count for sheet {sheet_title(sheet)
- Missing sheet_id for sheet {title!r}
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/198369070d14382c.
Report an issue: GitHub.