larksuite/cli · error

%s.Items is required

Error message

%s.Items is required

What it means

validateShape rejects a typedArrayShape whose Items shape is nil. Every array shape must declare the shape of its elements so the generated schema can describe item constraints; a nil Items is reported with the array's path plus the '.Items' suffix convention.

Source

Thrown at shortcuts/common/typed_compile_data.go:290

			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 {
			return fmt.Errorf("%s const is not JSON-encodable: %w", path, err)
		}
	case typedArrayShape:
		if value.Items == nil {
			return fmt.Errorf("%s.Items is required", path)
		}
		if value.MinItems != nil && *value.MinItems < 0 || value.MaxItems != nil && *value.MaxItems < 0 {
			return fmt.Errorf("%s item lengths must be nonnegative", path)
		}
		if value.MinItems != nil && value.MaxItems != nil && *value.MinItems > *value.MaxItems {
			return fmt.Errorf("%s minItems exceeds maxItems", path)
		}
		return validateShape(value.Items, path+".Items")
	case typedObjectShape:
		seen := make(map[string]struct{})
		for i := range value.Fields {
			field := &value.Fields[i]
			if field.Name == "" {
				return fmt.Errorf("%s.Fields[%d].Name is required", path, i)
			}
			if _, duplicate := seen[field.Name]; duplicate {
				return fmt.Errorf("%s contains duplicate field %q", path, field.Name)
			}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Find the array shape at the reported path (the error is raised as '<path>.Items is required').
  2. Set Items to a concrete shape, e.g. typedStringShape{} or a nested typedObjectShape.
  3. For heterogeneous items, use typedOneOfShape with at least two variants as Items.
  4. Cover the shape literal in a test that runs the compile path.

Example fix

// before
shape := typedArrayShape{} // Items missing
// after
shape := typedArrayShape{Items: typedStringShape{}}
Defensive patterns

Strategy: validation

Validate before calling

func arrayItemsSet(s typedValueShape) error {
    if arr, ok := s.(typedArrayShape); ok && arr.Items == nil {
        return errors.New("array shape missing Items")
    }
    return nil
}
// if err := arrayItemsSet(shape); err != nil { return err }

Type guard

func isArrayShapeWithItems(s typedValueShape) bool {
    arr, ok := s.(typedArrayShape)
    return ok && arr.Items != nil
}

Prevention

When it happens

Trigger: An explicit Output.Data.Shape or DataField.Shape override constructs typedArrayShape{} without setting Items; a programmatic shape builder returns nil for the element shape; validateShape recursion reaches the array during compileData.

Common situations: Hand-writing an array shape literal and forgetting the element type; refactoring that removed an Items assignment; copy-pasting a shape template and leaving the placeholder nil.

Related errors


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