larksuite/cli · error
%s is nil
Error message
%s is nil
What it means
validateShape rejects a typedValueShape that is nil at the given JSON-pointer-like path. Shapes are built either by compileStructShape/lowerAuthoringShape or supplied explicitly via Output.Data.Shape; a nil shape means the compiler produced nothing or an authoring shape slot was left empty. It is a startup-time guard preventing a nil shape from reaching schema generation or request execution.
Source
Thrown at shortcuts/common/typed_compile_data.go:258
if isNilCapable(field.Type) && schema.nullable == nil {
return typedObjectShape{}, fmt.Errorf("%s field %s (%s): nil-capable field must declare nullable or nonnullable", path, field.Name, name)
}
description := strings.TrimSpace(field.Tag.Get("doc"))
if input && description == "" {
return typedObjectShape{}, fmt.Errorf("%s field %s (%s): description is required via doc", path, field.Name, name)
}
fieldShape, err := shapeForType(field.Type, schema, input, active)
if err != nil {
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) {View on GitHub (pinned to 7fd6ef3c07)
Solutions
- Identify the empty slot from the path prefix in the message (e.g. Output.Data.Shape.Items).
- Set the missing nested shape: every typedArrayShape must have Items, every typedOneOfShape needs non-nil variants, every object field needs a Shape.
- If using an explicit Shape, prefer a struct-derived shape or a fully populated authoring shape literal.
- If a custom lowering step produced nil, fix it to return a concrete shape or a descriptive error instead.
Example fix
// before
shape := typedArrayShape{} // Items left nil
// after
shape := typedArrayShape{Items: typedStringShape{MinLength: intPtr(1)}} Defensive patterns
Strategy: validation
Validate before calling
func hasNilShapeSlot(s typedValueShape) bool {
switch v := s.(type) {
case typedArrayShape:
return v.Items == nil || hasNilShapeSlot(v.Items)
case typedOneOfShape:
for _, variant := range v.Variants {
if variant == nil || hasNilShapeSlot(variant) { return true }
}
case typedObjectShape:
for _, f := range v.Fields {
if f.Shape == nil || hasNilShapeSlot(f.Shape) { return true }
}
}
return false
}
// call before handing the shape to the command definition
// if hasNilShapeSlot(myShape) { return errors.New("shape has nil slots") } Type guard
func isShapeSet(s typedValueShape) bool { return s != nil } Prevention
- Always set Items on array shapes and at least two non-nil variants on oneOf shapes.
- Prefer deriving shapes from Go structs via compileData instead of hand-authoring literals.
- Check lowering/override helpers for paths that can silently return nil.
- Add a unit test that runs validateShape over every declared command shape.
When it happens
Trigger: An explicit Output.Data.Shape (or a nested Items/Variants/field slot inside it) is nil after lowering; validateShape is called recursively (e.g. on typedArrayShape.Items or a oneOf variant) and encounters a nil entry. Also reachable via mergeInputSupplement and DataField.Shape overrides.
Common situations: Hand-authoring an Output.Data.Shape literal and leaving an Items or variant field unset; an override replaces a field with a shape that fails to lower to nil; constructing shapes programmatically where an error path silently returns nil.
Related errors
- L1: inputSchema must not be nil
- L1: inputSchema.properties must not be nil
- L1: outputSchema must not be nil
- L1: _meta must not be nil
- %s string lengths must be nonnegative
AI-assisted analysis of larksuite/cli@7fd6ef3c07 (2026-09-04).
Data as JSON: /api/errors/b5ba313bb0f9ec85.
Report an issue: GitHub.