{"record":{"id":"0f51a1daae416545","repo":"larksuite/cli","slug":"data-must-be-a-non-pointer-struct-or-any-unless-ou","errorCode":null,"errorMessage":"Data must be a non-pointer struct or any unless Output.Data.Shape is explicit, got %s","messagePattern":"Data must be a non-pointer struct or any unless Output\\.Data\\.Shape is explicit, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/common/typed_compile_data.go","lineNumber":44,"sourceCode":"\t}\n\tif definition.Shape != nil {\n\t\tshape, err := lowerAuthoringShape(definition.Shape)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif err := validateShape(shape, \"Output.Data.Shape\"); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn shape, nil\n\t}\n\tif dataType.Kind() == reflect.Interface && dataType.NumMethod() == 0 {\n\t\tif len(definition.Overrides) > 0 {\n\t\t\treturn nil, fmt.Errorf(\"Output.Data.Overrides require struct Data\")\n\t\t}\n\t\treturn anyJSONShape{}, nil\n\t}\n\tif dataType.Kind() != reflect.Struct {\n\t\treturn nil, fmt.Errorf(\"Data must be a non-pointer struct or any unless Output.Data.Shape is explicit, got %s\", dataType)\n\t}\n\tshape, err := compileStructShape(dataType, false, \"Data\", map[reflect.Type]struct{}{})\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tfor i, override := range definition.Overrides {\n\t\tif override.Path == \"\" || !strings.HasPrefix(override.Path, \"/\") {\n\t\t\treturn nil, fmt.Errorf(\"Output.Data.Overrides[%d].Path %q must be an RFC 6901 JSON Pointer\", i, override.Path)\n\t\t}\n\t\tif err := applyDataOverride(&shape, override); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"Output.Data.Overrides[%d] path %q: %w\", i, override.Path, err)\n\t\t}\n\t}\n\tif err := validateShape(shape, \"Output.Data\"); err != nil {\n\t\treturn nil, err\n\t}\n\treturn shape, nil\n}","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compile_data.go#L26-L62","documentation":"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.","triggerScenarios":"Declaring Output.Data as *T, []T, map[string]T, string, etc., without providing an explicit Output.Data.Shape, then compiling the definition.","commonSituations":"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.","solutions":["Change Data to a non-pointer struct type (remove the * if present).","Or supply an explicit Output.Data.Shape describing the non-struct payload.","For collections, wrap them in a struct field, e.g. type data struct{ Items []T `json:\"items\"` }."],"exampleFix":"// before\nData *MyData\n// after\nData MyData","handlingStrategy":"validation","validationCode":"func checkDataKind(dataType reflect.Type, hasShape bool) error {\n  if hasShape { return nil }\n  switch {\n  case dataType.Kind() == reflect.Interface && dataType.NumMethod() == 0:\n    return nil\n  case dataType.Kind() == reflect.Struct:\n    return nil\n  default:\n    return fmt.Errorf(\"Data must be non-pointer struct or any, got %s\", dataType)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare Data as T, never *T, for output definitions","Wrap maps/slices in a struct with a single field","Or supply an explicit Shape when the payload is not a struct"],"tags":["configuration","reflection","struct","shortcuts"],"backgroundTag":"data-must-be-struct-or-any","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}