larksuite/cli · error
%s item lengths must be nonnegative
Error message
%s item lengths must be nonnegative
What it means
Shape validation guard: a typed array shape declares a negative minItems or maxItems. Item-count bounds must be nonnegative.
Source
Thrown at shortcuts/common/typed_compile_data.go:293
for _, number := range append(append([]float64{}, value.Enum...), pointerFloats(value.Minimum, value.Maximum)...) {
if math.IsNaN(number) || math.IsInf(number, 0) {
return fmt.Errorf("%s number constraints must be finite", path)
}
}
if value.Minimum != nil && value.Maximum != nil && *value.Minimum > *value.Maximum {
return fmt.Errorf("%s minimum exceeds maximum", path)
}
case typedNullShape:
case typedConstShape:
if _, err := json.Marshal(value.Value); err != nil {
return fmt.Errorf("%s const is not JSON-encodable: %w", path, err)
}
case typedArrayShape:
if value.Items == nil {
return fmt.Errorf("%s.Items is required", path)
}
if value.MinItems != nil && *value.MinItems < 0 || value.MaxItems != nil && *value.MaxItems < 0 {
return fmt.Errorf("%s item lengths must be nonnegative", path)
}
if value.MinItems != nil && value.MaxItems != nil && *value.MinItems > *value.MaxItems {
return fmt.Errorf("%s minItems exceeds maxItems", path)
}
return validateShape(value.Items, path+".Items")
case typedObjectShape:
seen := make(map[string]struct{})
for i := range value.Fields {
field := &value.Fields[i]
if field.Name == "" {
return fmt.Errorf("%s.Fields[%d].Name is required", path, i)
}
if _, duplicate := seen[field.Name]; duplicate {
return fmt.Errorf("%s contains duplicate field %q", path, field.Name)
}
seen[field.Name] = struct{}{}
if strings.TrimSpace(field.Description) == "" {
return fmt.Errorf("%s field %q Description is required", path, field.Name)View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Locate the array shape at the reported path and inspect MinItems/MaxItems.
- Set the negative bound to a nonnegative integer or remove the pointer to drop the constraint.
- Clamp computed values with max(0, n) before assignment.
- Add a compile-path test asserting the bounds.
Example fix
// before
typedArrayShape{Items: typedStringShape{}, MinItems: intPtr(-3)}
// after
typedArrayShape{Items: typedStringShape{}, MinItems: intPtr(0)} Defensive patterns
Strategy: validation
Validate before calling
func validItemCountBounds(s typedArrayShape) bool {
nonneg := func(p *int) bool { return p == nil || *p >= 0 }
return nonneg(s.MinItems) && nonneg(s.MaxItems)
}
// if !validItemCountBounds(shape) { return errors.New("negative item-count bound") } Type guard
func hasNegativeItemCount(p *int) bool { return p != nil && *p < 0 } Prevention
- Use nil pointers, not negative values, for 'no item-count limit'.
- Clamp derived counts with max(0, n) before assignment.
- Author minItems/maxItems together and add compile-path tests.
When it happens
Trigger: An explicit Output.Data.Shape or DataField.Shape override declares typedArrayShape with a negative MinItems/MaxItems; or schema tag values lowered into the shape (minItems/maxItems) are negative.
Common situations: Typo'd negative constants in shape literals or tags; computed bounds from a length差 or config default that underflows; copy-paste sign errors when duplicating a constraint.
Related errors
- %s.Items is required
- L1: inputSchema must not be nil
- L1: inputSchema.properties must not be nil
- L1: outputSchema must not be nil
- L1: _meta must not be nil
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/43b47259df3e2dec.
Report an issue: GitHub.