larksuite/cli · error
%s must contain at least %d items
Error message
%s must contain at least %d items
What it means
Typed array shape validation: the supplied array has fewer items than the declared minItems constraint.
Source
Thrown at shortcuts/common/typed_binder.go:474
return fmt.Errorf("%s must be a number", path)
}
if len(constraint.Enum) > 0 && !slices.Contains(constraint.Enum, number) {
return fmt.Errorf("%s has an unsupported number value", path)
}
if constraint.Minimum != nil && number < *constraint.Minimum {
return fmt.Errorf("%s must be at least %v", path, *constraint.Minimum)
}
if constraint.Maximum != nil && number > *constraint.Maximum {
return fmt.Errorf("%s must be at most %v", path, *constraint.Maximum)
}
return nil
case typedArrayShape:
items, ok := value.([]any)
if !ok {
return fmt.Errorf("%s must be an array", path)
}
if constraint.MinItems != nil && len(items) < *constraint.MinItems {
return fmt.Errorf("%s must contain at least %d items", path, *constraint.MinItems)
}
if constraint.MaxItems != nil && len(items) > *constraint.MaxItems {
return fmt.Errorf("%s must contain at most %d items", path, *constraint.MaxItems)
}
for i, item := range items {
if err := validateJSONValueAgainstShape(item, constraint.Items, fmt.Sprintf("%s[%d]", path, i)); err != nil {
return err
}
}
return nil
case typedObjectShape:
object, ok := value.(map[string]any)
if !ok {
return fmt.Errorf("%s must be an object", path)
}
fields := make(map[string]typedValueField, len(constraint.Fields))
for _, field := range constraint.Fields {
fields[field.Name] = fieldView on GitHub (pinned to 7fd6ef3c07)
Solutions
- Supply at least the required number of items in the array.
- Guard the caller: skip the command or handle the empty case before invoking when the list may be empty.
- Check --help/schema for the documented minimum length.
- If the API genuinely allows empty lists, verify the shape constraint against upstream metadata.
Example fix
// before lark-cli shortcut demo --user-ids '[]' // error: user_ids must contain at least 1 items // after lark-cli shortcut demo --user-ids '["ou_x"]'
Defensive patterns
Strategy: validation
Validate before calling
ids=$(jq -c '.user_ids // []' payload.json) len=$(echo "$ids" | jq 'length') if [ "$len" -lt 1 ]; then echo "user_ids needs at least 1 item; skipping call" >&2; exit 2 fi
Type guard
func hasMinItems[T any](xs []T, n int) bool { return len(xs) >= n } Try / catch
err := cmd.Run()
if err != nil && strings.Contains(err.Error(), "must contain at least") {
// handle the empty-collection case upstream instead of calling
} Prevention
- Skip the command entirely when the source list is empty.
- Validate array length with jq before invocation.
- Check MinItems in the schema for the field.
- Avoid building arrays from unguarded empty results.
When it happens
Trigger: Passing an empty array or an array with too few elements to a field whose shape declares MinItems — e.g. --user-ids '[]' where at least 1 user id is required.
Common situations: Automated pipelines submitting empty lists when the upstream collection is empty instead of skipping the call; copying examples trimmed down; loops that build arrays from zero results.
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
- %s must contain at most %d items
- please select at least one domain
- %s must contain at most %d characters
- %s must be one of: %s
- %s must be a boolean
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/dc40c847a41c54e0.
Report an issue: GitHub.