larksuite/cli · error

field %q: %w

Error message

field %q: %w

What it means

lowerAuthoringShape converts public command.ValueShape authoring types into internal lowered shapes. When lowering an ObjectShape, each field's shape is lowered recursively; this wrapper wraps any child failure with the field name so the author can locate the bad field. The inner error is usually 'unsupported public shape %T' from a nested field.

Source

Thrown at shortcuts/common/typed_shape.go:110

		}, nil
	case command.NullShape:
		return typedNullShape{}, nil
	case command.ConstShape:
		return typedConstShape{Value: cloneJSONValue(value.Value)}, nil
	case command.ArrayShape:
		items, err := lowerAuthoringShape(value.Items)
		if err != nil {
			return nil, err
		}
		return typedArrayShape{
			Items: items, MinItems: cloneScalarPointer(value.MinItems), MaxItems: cloneScalarPointer(value.MaxItems),
		}, nil
	case command.ObjectShape:
		fields := make([]typedValueField, len(value.Fields))
		for index, field := range value.Fields {
			fieldShape, err := lowerAuthoringShape(field.Shape)
			if err != nil {
				return nil, fmt.Errorf("field %q: %w", field.Name, err)
			}
			fields[index] = typedValueField{
				Name: field.Name, Description: field.Description, Required: field.Required, Shape: fieldShape,
			}
		}
		additional, err := lowerAuthoringShape(value.AdditionalPropertiesShape)
		if err != nil {
			return nil, err
		}
		return typedObjectShape{
			Fields: fields, AdditionalProperties: value.AdditionalProperties,
			AdditionalPropertiesShape: additional,
		}, nil
	case command.OneOfShape:
		variants := make([]typedValueShape, len(value.Variants))
		for index, variant := range value.Variants {
			lowered, err := lowerAuthoringShape(variant)
			if err != nil {

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Read the full wrapped error chain: 'field "x": ... unsupported public shape <T>' tells you the offending field and type.
  2. Replace the offending field's Shape value with a supported constructor (command.StringShape{}, command.ObjectShape{...}, etc.).
  3. Check for nil interface carrying a typed nil pointer; use the concrete zero value of the shape type instead.

Example fix

// before
fields: []command.DataField{{ Name: "owner", Shape: myCustomShape{} }} // unsupported type
// after
fields: []command.DataField{{ Name: "owner", Shape: command.StringShape{Format: "open_id"} }}
Defensive patterns

Strategy: validation

Validate before calling

// Validate shapes before compiling the input definition:
func checkShape(s command.ValueShape) error {
    switch t := s.(type) {
    case nil, command.StringShape, command.BooleanShape, command.IntegerShape,
        command.NumberShape, command.NullShape, command.ConstShape,
        command.ArrayShape, command.ObjectShape, command.OneOfShape:
        return nil
    default:
        return fmt.Errorf("unsupported shape %T", t)
    }
}

Type guard

func isSupportedShape(s command.ValueShape) bool {
    switch s.(type) {
    case nil, command.StringShape, command.BooleanShape, command.IntegerShape,
        command.NumberShape, command.NullShape, command.ConstShape,
        command.ArrayShape, command.ObjectShape, command.OneOfShape:
        return true
    }
    return false
}

Prevention

When it happens

Trigger: Declaring a Typed input object whose field.Shape is nil-typed-but-non-nil interface, or a custom type that does not implement one of the supported command.ValueShape variants (String/Boolean/Integer/Number/Null/Const/Array/Object/OneOf).

Common situations: Hand-rolling a shape struct instead of using the command package's shape constructors; passing a *T pointer or map literal where a concrete shape type is expected; copy-paste from older shortcut code using a removed shape type.

Related errors


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