larksuite/cli · error
schema minItems: %w
Error message
schema minItems: %w
What it means
parseSchemaTag validates each `schema` struct tag token on typed shortcut argument fields. The `minItems` token requires a non-negative integer; when parseNonnegativeInt fails (missing value, non-numeric, negative, or out-of-range), the parser wraps that error with this prefix and aborts schema compilation for the field.
Source
Thrown at shortcuts/common/typed_compile_args.go:481
return result, fmt.Errorf("schema maxLength: %w", err)
}
result.maxLength = &v
case "minimum":
v, err := parseFiniteFloat(value)
if err != nil {
return result, fmt.Errorf("schema minimum: %w", err)
}
result.minimum = &v
case "maximum":
v, err := parseFiniteFloat(value)
if err != nil {
return result, fmt.Errorf("schema maximum: %w", err)
}
result.maximum = &v
case "minItems":
v, err := parseNonnegativeInt(value)
if err != nil {
return result, fmt.Errorf("schema minItems: %w", err)
}
result.minItems = &v
case "maxItems":
v, err := parseNonnegativeInt(value)
if err != nil {
return result, fmt.Errorf("schema maxItems: %w", err)
}
result.maxItems = &v
default:
return result, fmt.Errorf("unknown schema token %q", key)
}
}
if result.required == result.optional {
return result, fmt.Errorf("schema must declare exactly one of required or optional")
}
if result.required && result.defaultValue.Set {
return result, fmt.Errorf("required input cannot declare default")
}View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Set minItems to a plain non-negative integer, e.g. schema:"required;minItems=1".
- Remove leading/trailing spaces around the value inside the tag.
- If no minimum is needed, delete the minItems token entirely.
Example fix
// before Query []string `schema:"required;minItems=-1"` // after Query []string `schema:"required;minItems=1"`
Defensive patterns
Strategy: validation
Validate before calling
func validMinItems(tag string) bool {
for _, tok := range strings.Split(tag, ";") {
if k, v, ok := strings.Cut(tok, "="); ok && k == "minItems" {
n, err := strconv.Atoi(v)
return err == nil && n >= 0
}
}
return true
} Prevention
- Only use plain non-negative integers for minItems.
- Run the test suite; parseSchemaTag errors surface in compile-time shortcut tests.
- Never embed spaces inside tag values.
When it happens
Trigger: Declaring a struct field tag like `schema:"required;minItems=abc"`, `minItems=` (empty), `minItems=-1`, or an oversized number, on a field collected via collectArgFields/compileStructShape.
Common situations: Typos in the tag (letters, stray spaces inside the value), copy-pasted negative bounds, or hand-written tags edited after a refactor.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- schema maxItems: %w
- schema must declare exactly one of required or optional
- unknown schema token %q
- required input cannot declare default
- nullable requires a nil-capable Go type
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/508dbc70a8c1510f.
Report an issue: GitHub.