larksuite/cli · error

Data must be a non-pointer struct or any unless Output.Data.

Error message

Data must be a non-pointer struct or any unless Output.Data.Shape is explicit, got %s

What it means

compileData requires Data to be either an explicit-Shape definition, an empty interface (any), or a non-pointer struct; any other kind (pointer, slice, map, scalar) is rejected with the offending reflect type printed. Overrides and shape compilation depend on struct reflection.

Source

Thrown at shortcuts/common/typed_compile_data.go:44

	}
	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)
		}
	}
	if err := validateShape(shape, "Output.Data"); err != nil {
		return nil, err
	}
	return shape, nil
}

View on GitHub (pinned to 7fd6ef3c07)

Solutions

  1. Change Data to a non-pointer struct type (remove the * if present).
  2. Or supply an explicit Output.Data.Shape describing the non-struct payload.
  3. For collections, wrap them in a struct field, e.g. type data struct{ Items []T `json:"items"` }.

Example fix

// before
Data *MyData
// after
Data MyData
Defensive patterns

Strategy: validation

Validate before calling

func checkDataKind(dataType reflect.Type, hasShape bool) error {
  if hasShape { return nil }
  switch {
  case dataType.Kind() == reflect.Interface && dataType.NumMethod() == 0:
    return nil
  case dataType.Kind() == reflect.Struct:
    return nil
  default:
    return fmt.Errorf("Data must be non-pointer struct or any, got %s", dataType)
  }
}

Prevention

When it happens

Trigger: Declaring Output.Data as *T, []T, map[string]T, string, etc., without providing an explicit Output.Data.Shape, then compiling the definition.

Common situations: Using pointer structs by habit; switching Data to a map for flexibility without adding an explicit Shape; refactoring a struct into a slice of items.

Related errors


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