{"record":{"id":"deff783e14703869","repo":"larksuite/cli","slug":"hooks-execute-is-required","errorCode":null,"errorMessage":"Hooks.Execute is required","messagePattern":"Hooks\\.Execute is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"shortcuts/common/typed_compiler.go","lineNumber":44,"sourceCode":"\t\treturn nil, err\n\t}\n\tfields, fieldByName, err := compileInput(argsType, input)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\trelations, err := compileRelations(input.Relations, fieldByName)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := compileAuthorization(metadata.Authorization, fields, fieldByName); err != nil {\n\t\treturn nil, err\n\t}\n\tdataShape, err := compileData(dataType, output.Data)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif hooks.execute == nil {\n\t\treturn nil, fmt.Errorf(\"Hooks.Execute is required\")\n\t}\n\tif err := validateOutput(output, dataShape); err != nil {\n\t\treturn nil, err\n\t}\n\tif err := validateOutputHooks(output, renderers); err != nil {\n\t\treturn nil, err\n\t}\n\tcommand := &compiledCommand{\n\t\tmetadata:    metadata,\n\t\targsType:    argsType,\n\t\tdataType:    dataType,\n\t\tfields:      fields,\n\t\tfieldByName: fieldByName,\n\t\trelations:   relations,\n\t\tdataShape:   dataShape,\n\t\toutput:      output,\n\t\thooks:       hooks,\n\t\tpageOutput:  pageOutput,","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/common/typed_compiler.go#L26-L62","documentation":"The typed command bridge requires an Execute hook: the function that performs the command's actual work and returns its data. compileDefinitionParts rejects any definition whose compiledHooks.execute is nil, because a command without an executor can never produce output. This is a build/startup-time declaration error, not a runtime failure.","triggerScenarios":"CompileCommandDefinition (or defineTypedCommand) invoked with Hooks whose Execute field is nil — e.g. common.Hooks{} with no Execute assigned, or a nil function variable passed as Execute.","commonSituations":"Scaffolding a new command and forgetting to implement Execute; deliberately commenting out Execute during debugging; wiring hooks from a struct whose Execute field was never populated.","solutions":["Implement and assign Hooks.Execute before compiling the definition.","If the command is not ready, remove its definition entirely rather than registering it without an executor.","Verify the hooks struct/value passed to the bridge is fully initialized (not a typed-nil function)."],"exampleFix":"// before\nvar cmd = common.Define(..., common.Hooks{})\n// after\nvar cmd = common.Define(..., common.Hooks{\n  Execute: func(ctx context.Context, rt *common.RuntimeContext, args Args) (Data, error) { ... },\n})","handlingStrategy":"validation","validationCode":"if hooks.Execute == nil {\n  return fmt.Errorf(\"command %s: Hooks.Execute must be assigned before definition\", name)\n}","typeGuard":"func executeReady(h common.Hooks) bool { return h.Execute != nil }","tryCatchPattern":null,"preventionTips":["Always define Execute together with the command definition in the same commit.","Avoid nil function variables for hooks; write the function literal inline.","If a command is unfinished, keep it unregistered until Execute exists."],"tags":["hooks","missing-required-field","compile-time"],"backgroundTag":"missing-required-callback","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"}