larksuite/cli · error

%s minLength exceeds maxLength

Error message

%s minLength exceeds maxLength

What it means

validateShape rejects a typedStringShape where both MinLength and MaxLength are set and MinLength is greater than MaxLength. Such a range admits no valid string, so the declaration is rejected at startup with the shape path included.

Source

Thrown at shortcuts/common/typed_compile_data.go:267

			return typedObjectShape{}, fmt.Errorf("%s field %s (%s): %w", path, field.Name, name, err)
		}
		shape.Fields = append(shape.Fields, typedValueField{Name: name, Description: description, Required: schema.required, Shape: fieldShape})
	}
	return shape, nil
}

func validateShape(shape typedValueShape, path string) error {
	if shape == nil {
		return fmt.Errorf("%s is nil", path)
	}
	switch value := shape.(type) {
	case anyJSONShape:
	case typedStringShape:
		if value.MinLength != nil && *value.MinLength < 0 || value.MaxLength != nil && *value.MaxLength < 0 {
			return fmt.Errorf("%s string lengths must be nonnegative", path)
		}
		if value.MinLength != nil && value.MaxLength != nil && *value.MinLength > *value.MaxLength {
			return fmt.Errorf("%s minLength exceeds maxLength", path)
		}
	case typedBooleanShape:
	case typedIntegerShape:
		if value.Minimum != nil && value.Maximum != nil && *value.Minimum > *value.Maximum {
			return fmt.Errorf("%s minimum exceeds maximum", path)
		}
	case typedNumberShape:
		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 {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Compare MinLength and MaxLength at the reported path; ensure min <= max.
  2. Swap the values if they were transposed, or raise MaxLength / lower MinLength.
  3. Remove one bound if only a single-sided constraint is intended.
  4. Add a unit test that builds the shape so contradictions fail in tests before startup.

Example fix

// before
typedStringShape{MinLength: intPtr(10), MaxLength: intPtr(5)}
// after
typedStringShape{MinLength: intPtr(5), MaxLength: intPtr(10)}
Defensive patterns

Strategy: validation

Validate before calling

func validStringRange(s typedStringShape) bool {
    return s.MinLength == nil || s.MaxLength == nil || *s.MinLength <= *s.MaxLength
}
// if !validStringRange(shape) { return errors.New("minLength exceeds maxLength") }

Prevention

When it happens

Trigger: An explicit Output.Data.Shape or DataField.Shape override declares a string shape with contradictory bounds, e.g. MinLength=10, MaxLength=5; or bounds swapped when programmatically deriving min/max from data.

Common situations: Swapping the two values by argument-order mistakes in a helper; refactoring that renames/reorders fields and shifts the bounds; tightening min without raising max.

Related errors


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