larksuite/cli · error
minLength exceeds maxLength
Error message
minLength exceeds maxLength
What it means
When both `minLength` and `maxLength` are declared in a schema tag, the minimum must not exceed the maximum; otherwise the constraint set is unsatisfiable and no value could ever validate. parseSchemaTag rejects this contradiction at compile time.
Source
Thrown at shortcuts/common/typed_compile_args.go:504
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")
}
if result.nullable != nil && *result.nullable && !isNilCapable(valueType) {
return result, fmt.Errorf("nullable requires a nil-capable Go type")
}
if result.minLength != nil && result.maxLength != nil && *result.minLength > *result.maxLength {
return result, fmt.Errorf("minLength exceeds maxLength")
}
if result.minimum != nil && result.maximum != nil && *result.minimum > *result.maximum {
return result, fmt.Errorf("minimum exceeds maximum")
}
if result.minItems != nil && result.maxItems != nil && *result.minItems > *result.maxItems {
return result, fmt.Errorf("minItems exceeds maxItems")
}
return result, nil
}
func parseCLITag(raw string) (typedCLIInput, error) {
var result typedCLIInput
if raw == "" {
return result, nil
}
seen := make(map[string]struct{})
for _, token := range strings.Split(raw, ";") {
key, value, ok := strings.Cut(token, "=")View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Ensure minLength <= maxLength in the tag.
- Swap the values if they were written in the wrong order.
- Relax one bound so the range is non-empty.
Example fix
// before Code string `schema:"required;minLength=10;maxLength=5"` // after Code string `schema:"required;minLength=5;maxLength=10"`
Defensive patterns
Strategy: validation
Validate before calling
func lengthRangeOK(min, max *int) bool {
return min == nil || max == nil || *min <= *max
} Prevention
- Write bounds as a contiguous range and re-read the tag before committing.
- Change both ends of a range together.
- Cover every input struct with a compile test so invalid ranges fail CI.
When it happens
Trigger: A tag like schema:"required;minLength=10;maxLength=5" on a string-typed input field.
Common situations: Swapping the two values when writing the tag, or independently tightening minLength / loosening maxLength during refactors without cross-checking.
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
- minimum exceeds maximum
- minItems exceeds maxItems
- schema minItems: %w
- schema maxItems: %w
- unknown schema token %q
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/c75d3d906a008c54.
Report an issue: GitHub.