larksuite/cli · error

minItems exceeds maxItems

Error message

minItems exceeds maxItems

What it means

When both `minItems` and `maxItems` are declared for a slice/array input, the minimum item count must not exceed the maximum. An inverted range is unsatisfiable, so parseSchemaTag rejects it at compile time.

Source

Thrown at shortcuts/common/typed_compile_args.go:510

		}
	}
	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, "=")
		if !ok || value == "" || token != strings.TrimSpace(token) {
			return result, fmt.Errorf("invalid cli token %q", token)
		}
		if _, duplicate := seen[key]; duplicate {
			return result, fmt.Errorf("cli token %q is duplicated", key)
		}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Ensure minItems <= maxItems in the tag.
  2. Swap the values if inverted.
  3. Drop one bound if only a single limit applies.

Example fix

// before
IDs []string `schema:"required;minItems=5;maxItems=2"`
// after
IDs []string `schema:"required;minItems=2;maxItems=5"`
Defensive patterns

Strategy: validation

Validate before calling

func itemsRangeOK(min, max *int) bool {
	return min == nil || max == nil || *min <= *max
}

Prevention

When it happens

Trigger: A tag like schema:"required;minItems=5;maxItems=2" on a slice-typed input field.

Common situations: Writing bounds in reverse order, or tightening minItems during a schema change without checking maxItems.

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


AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04). Data as JSON: /api/errors/f7a3af4005f2d984. Report an issue: GitHub.