larksuite/cli · error

Output.Data.Overrides require struct Data

Error message

Output.Data.Overrides require struct Data

What it means

When the Data type is the empty interface (any), compileData returns a permissive anyJSONShape, but Overrides only make sense against a concrete struct-derived shape; providing Overrides with an `any` Data type is therefore rejected because there are no fields to point into.

Source

Thrown at shortcuts/common/typed_compile_data.go:39

)

func compileData(dataType reflect.Type, definition typedDataDefinition) (typedValueShape, error) {
	if definition.Shape != nil && len(definition.Overrides) > 0 {
		return nil, fmt.Errorf("Output.Data.Shape and Output.Data.Overrides are mutually exclusive")
	}
	if definition.Shape != nil {
		shape, err := lowerAuthoringShape(definition.Shape)
		if err != nil {
			return nil, err
		}
		if err := validateShape(shape, "Output.Data.Shape"); err != nil {
			return nil, err
		}
		return shape, nil
	}
	if dataType.Kind() == reflect.Interface && dataType.NumMethod() == 0 {
		if len(definition.Overrides) > 0 {
			return nil, fmt.Errorf("Output.Data.Overrides require struct Data")
		}
		return anyJSONShape{}, nil
	}
	if dataType.Kind() != reflect.Struct {
		return nil, fmt.Errorf("Data must be a non-pointer struct or any unless Output.Data.Shape is explicit, got %s", dataType)
	}
	shape, err := compileStructShape(dataType, false, "Data", map[reflect.Type]struct{}{})
	if err != nil {
		return nil, err
	}
	for i, override := range definition.Overrides {
		if override.Path == "" || !strings.HasPrefix(override.Path, "/") {
			return nil, fmt.Errorf("Output.Data.Overrides[%d].Path %q must be an RFC 6901 JSON Pointer", i, override.Path)
		}
		if err := applyDataOverride(&shape, override); err != nil {
			return nil, fmt.Errorf("Output.Data.Overrides[%d] path %q: %w", i, override.Path, err)
		}
	}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Change Output.Data to a concrete non-pointer struct type whose fields the overrides target.
  2. Remove the Overrides and keep Data as `any` for free-form JSON passthrough.
  3. If the payload is dynamic but partially fixed, define a struct with an `any`-typed field and override into that field.

Example fix

// before
Data any; Overrides: []Override{{Path:"/name", Value:"x"}}
// after
type data struct { Name string `json:"name"` }
Data data; Overrides: []Override{{Path:"/name", Value:"x"}}
Defensive patterns

Strategy: validation

Validate before calling

func overridesNeedStruct(dataType reflect.Type, n int) error {
  if dataType.Kind() == reflect.Interface && dataType.NumMethod() == 0 && n > 0 {
    return errors.New("Overrides require a struct Data type")
  }
  return nil
}

Prevention

When it happens

Trigger: Declaring Output.Data as `any` (reflect.Interface with NumMethod()==0) while also supplying Output.Data.Overrides to compileData/compileDefinitionParts.

Common situations: Leaving Data as `any` for dynamic payloads but still configuring legacy override paths; template code that kept `any` after adding overrides.

Related errors


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