larksuite/cli · error
%sarray has %d items, minimum is %d
Error message
%sarray has %d items, minimum is %d
What it means
Schema validation error from collectSchemaErrors: an array flag value has fewer items than the schema's `minItems`. The intermediate error is wrapped by validateFlagAgainstSchema into a typed flag validation error with a --print-schema hint.
Source
Thrown at shortcuts/sheets/flag_schema_validate.go:385
return // wrong container type — descending would cascade nonsense.
}
}
// Numeric bounds — only checked when value is a number (type mismatch
// already reported above). Apply to both `number` and `integer` types.
if num, ok := value.(float64); ok {
if schema.Minimum != nil && num < *schema.Minimum {
c.add(fmt.Errorf("%svalue %v is below minimum %v", pathPrefix(path), num, *schema.Minimum)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
}
if schema.Maximum != nil && num > *schema.Maximum {
c.add(fmt.Errorf("%svalue %v is above maximum %v", pathPrefix(path), num, *schema.Maximum)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
}
}
// Array length bounds — only checked when value is an array.
if arr, ok := value.([]interface{}); ok {
if schema.MinItems != nil && len(arr) < *schema.MinItems {
c.add(fmt.Errorf("%sarray has %d items, minimum is %d", pathPrefix(path), len(arr), *schema.MinItems)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
}
if schema.MaxItems != nil && len(arr) > *schema.MaxItems {
c.add(fmt.Errorf("%sarray has %d items, maximum is %d", pathPrefix(path), len(arr), *schema.MaxItems)) //nolint:forbidigo // intermediate error; validateFlagAgainstSchema wraps it into a typed flag validation error with a --print-schema hint
}
}
if len(schema.Enum) > 0 {
matched := false
for _, allowed := range schema.Enum {
if jsonEqual(allowed, value) {
matched = true
break
}
}
if !matched {
msg := fmt.Sprintf("%svalue %s is not in enum %s",
pathPrefix(path), formatJSONValue(value), formatEnum(schema.Enum))
if hint := suggestEnumForError(value, schema.Enum); hint != "" {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Ensure the array contains at least the minimum number of items required by the schema.
- Guard against empty lists: skip the call or error out upstream when the array is empty.
- Inspect the schema bounds with --print-schema before building the payload.
Example fix
// before
--values '[]' // minItems is 1
// after
--values '[{"row": 1}]' Defensive patterns
Strategy: validation
Validate before calling
const minItems = 1; // from schema
if (Array.isArray(arr) && arr.length < minItems) {
throw new Error(`array needs at least ${minItems} item(s), got ${arr.length}`);
} Type guard
function hasMinItems(v: unknown, min: number): v is unknown[] {
return Array.isArray(v) && v.length >= min;
} Prevention
- Skip the call entirely when a filtered list is empty instead of sending [].
- Assert array length before building the payload.
- Never default a minItems-bounded array to [].
When it happens
Trigger: Passing a JSON array flag with fewer elements than `minItems`, e.g. a batch operation requiring at least 1 item receiving an empty array `[]`.
Common situations: Filtering an upstream list before batching and ending up with zero rows; constructing arrays dynamically and not checking emptiness; defaulting an optional array to [].
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
- %sarray has %d items, maximum is %d
- %svalue %v is below minimum %v
- %svalue %v is above maximum %v
- %s
- %svalue does not match any of oneOf alternatives
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/1c06a147d3c06487.
Report an issue: GitHub.