larksuite/cli · error

L2: field minimum ( ) >= maximum ( )

Error message

L2: field %q minimum (%v) >= maximum (%v)

What it means

L2 schema lint failure: a field declares both minimum and maximum with minimum >= maximum, an unsatisfiable numeric range. Caught while walking the schema property tree before commands are generated.

Solutions

  1. Swap Minimum and Maximum if they were reversed
  2. Lower Minimum or raise Maximum so Minimum < Maximum
  3. Remove one bound if only a one-sided constraint is intended
  4. Fix the upstream metadata generation that produced equal/invalid bounds

Example fix

// before
Property{Minimum: &ten, Maximum: &ten}
// after
Property{Minimum: &one, Maximum: &ten}
Defensive patterns

Strategy: validation

Validate before calling

if p.Minimum != nil && p.Maximum != nil && *p.Minimum >= *p.Maximum {
  return fmt.Errorf("field %s: min %v >= max %v", name, *p.Minimum, *p.Maximum)
}

Type guard

func hasValidRange(p *Property) bool { return p.Minimum == nil || p.Maximum == nil || *p.Minimum < *p.Maximum }

Prevention

When it happens

Trigger: A property has non-nil Minimum and Maximum with *Minimum >= *Maximum (e.g. min:10 max:10, or min:5 max:1).

Common situations: Off-by-one when copying range bounds; metadata source where max was edited down; nullable pointers pointing at swapped values.

Related errors


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

Appendix: source

Thrown at internal/schema/lint.go:126

	return errs
}

// walkForL2 recursively applies per-field L2 checks (format:binary on
// non-string; minimum>=maximum) plus the sub-object required-exists invariant.
// Required only matters on object-typed Properties (e.g. the params / data
// wrappers); leaf scalars ignore it.
func walkForL2(props *OrderedProps, errs *[]error) {
	if props == nil {
		return
	}
	for _, k := range props.Order {
		p := props.Map[k]
		if p.Format == "binary" && p.Type != "string" {
			*errs = append(*errs, fmt.Errorf("L2: field %q has format: binary but type = %q (want string)", k, p.Type))
		}
		if p.Minimum != nil && p.Maximum != nil && *p.Minimum >= *p.Maximum {
			*errs = append(*errs, fmt.Errorf("L2: field %q minimum (%v) >= maximum (%v)", k, *p.Minimum, *p.Maximum))
		}
		if n := len(p.EnumDescriptions); n > 0 && n != len(p.Enum) {
			*errs = append(*errs, fmt.Errorf("L2: field %q enumDescriptions length (%d) != enum length (%d)", k, n, len(p.Enum)))
		}
		if len(p.Required) > 0 && p.Properties != nil {
			for _, r := range p.Required {
				if _, ok := p.Properties.Map[r]; !ok {
					*errs = append(*errs, fmt.Errorf("L2: required key %q in %q not found in its properties", r, k))
				}
			}
		}
		if p.Properties != nil {
			walkForL2(p.Properties, errs)
		}
	}
}

// validatePropertyTypes walks an OrderedProps tree and asserts:

View on GitHub (pinned to 7fd6ef3c07)