{"record":{"id":"68126d91d5ea0fe0","repo":"vxcontrol/pentagi","slug":"code-result-handler-is-required","errorCode":null,"errorMessage":"code result handler is required","messagePattern":"code result handler is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/tools.go","lineNumber":1177,"sourceCode":"\t\tfte.embedder,\n\t\tfte.db,\n\t\tfte.cfg.EmbeddingMaxTextBytes,\n\t\tfte.vslp,\n\t\tfte.knp,\n\t)\n\tif guide.IsAvailable() {\n\t\tce.definitions = append(ce.definitions, registryDefinitions[StoreGuideToolName])\n\t\tce.definitions = append(ce.definitions, registryDefinitions[SearchGuideToolName])\n\t\tce.handlers[StoreGuideToolName] = guide.Handle\n\t\tce.handlers[SearchGuideToolName] = guide.Handle\n\t}\n\n\treturn ce, nil\n}\n\nfunc (fte *flowToolsExecutor) GetCoderExecutor(cfg CoderExecutorConfig) (ContextToolsExecutor, error) {\n\tif cfg.CodeResult == nil {\n\t\treturn nil, fmt.Errorf(\"code result handler is required\")\n\t}\n\n\tif cfg.Adviser == nil {\n\t\treturn nil, fmt.Errorf(\"adviser handler is required\")\n\t}\n\n\tif cfg.Installer == nil {\n\t\treturn nil, fmt.Errorf(\"installer handler is required\")\n\t}\n\n\tif cfg.Memorist == nil {\n\t\treturn nil, fmt.Errorf(\"memorist handler is required\")\n\t}\n\n\tif cfg.Searcher == nil {\n\t\treturn nil, fmt.Errorf(\"searcher handler is required\")\n\t}\n","sourceCodeStart":1159,"sourceCodeEnd":1195,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/tools.go#L1159-L1195","documentation":"GetCoderExecutor (flowToolsExecutor, backend/pkg/tools/tools.go:1177) validates a CoderExecutorConfig before constructing the coder tool executor. It refuses to build the executor when cfg.CodeResult is nil, because without a code-result handler the agent's code-execution results would have nowhere to be delivered. The check is a fail-fast guard; the companion check for cfg.Adviser is applied right after.","triggerScenarios":"Calling GetCoderExecutor with a CoderExecutorConfig literal that omits the CodeResult field (zero-value struct or partial config), or passing a variable that was conditionally assigned only on some code path so it remains nil at call time.","commonSituations":"Wiring up a new flow executor during refactoring and forgetting to inject the code-result callback; building the config from environment/feature flags where the code-result handler is only initialized when code-execution is enabled; copying an example that used a different executor constructor.","solutions":["Set cfg.CodeResult to a non-nil handler (e.g. the flow's code-result processing function) before calling GetCoderExecutor.","Add a pre-call guard that validates required handlers (CodeResult, Adviser) and returns a descriptive error identifying which field is missing.","If code execution is intentionally disabled, skip GetCoderExecutor entirely instead of passing a partially-filled config.","Consider giving CoderExecutorConfig a constructor/builder that requires CodeResult so the zero-value config cannot be used."],"exampleFix":"// before\nexecutor, err := fte.GetCoderExecutor(CoderExecutorConfig{\n    Adviser: adviser,\n})\n// after\nexecutor, err := fte.GetCoderExecutor(CoderExecutorConfig{\n    CodeResult: flow.HandleCodeResult,\n    Adviser:    adviser,\n})","handlingStrategy":"validation","validationCode":"if cfg.CodeResult == nil {\n    return nil, fmt.Errorf(\"GetCoderExecutor: cfg.CodeResult must be set before calling\")\n}","typeGuard":"func (c CoderExecutorConfig) Valid() bool {\n    return c.CodeResult != nil && c.Adviser != nil\n}","tryCatchPattern":"executor, err := fte.GetCoderExecutor(cfg)\nif err != nil {\n    return nil, fmt.Errorf(\"building coder executor: %w\", err)\n}","preventionTips":["Always build CoderExecutorConfig through a single constructor that fills CodeResult and Adviser.","Add a unit test asserting GetCoderExecutor fails fast with a clear message for a zero-value config.","Wrap the construction error with %w so the missing-handler cause is visible in logs."],"tags":["go","config-validation","nil-handler","tools"],"backgroundTag":"missing-required-config-field","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}