{"record":{"id":"12dc401053b91d1c","repo":"apache/beam","slug":"enableprofcapturehook-s-not-registered","errorCode":null,"errorMessage":"EnableProfCaptureHook: %s not registered","messagePattern":"EnableProfCaptureHook: (.+?) not registered","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/x/hooks/perf/perf.go","lineNumber":150,"sourceCode":"\t}\n\thooks.RegisterHook(\"heap\", hf)\n}\n\n// RegisterProfCaptureHook registers a CaptureHookFactory for the\n// supplied identifier. It panics if the same identifier is\n// registered twice.\nfunc RegisterProfCaptureHook(name string, c CaptureHookFactory) {\n\tif _, exists := profCaptureHookRegistry[name]; exists {\n\t\tpanic(fmt.Sprintf(\"RegisterProfCaptureHook: %s registered twice\", name))\n\t}\n\tprofCaptureHookRegistry[name] = c\n}\n\n// EnableProfCaptureHook actives a registered profile capture hook for a given pipeline.\nfunc EnableProfCaptureHook(name string, opts ...string) {\n\t_, exists := profCaptureHookRegistry[name]\n\tif !exists {\n\t\tpanic(fmt.Sprintf(\"EnableProfCaptureHook: %s not registered\", name))\n\t}\n\n\tenc := hooks.Encode(name, opts)\n\n\tfor i, h := range enabledProfCaptureHooks {\n\t\tn, _ := hooks.Decode(h)\n\t\tif h == n {\n\t\t\t// Rewrite the registration with the current arguments\n\t\t\tenabledProfCaptureHooks[i] = enc\n\t\t\thooks.EnableHook(\"prof\", enabledProfCaptureHooks...)\n\t\t\treturn\n\t\t}\n\t}\n\n\tenabledProfCaptureHooks = append(enabledProfCaptureHooks, enc)\n\thooks.EnableHook(\"prof\", enabledProfCaptureHooks...)\n}\n","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/x/hooks/perf/perf.go#L132-L168","documentation":"EnableProfCaptureHook looks up the requested hook name in profCaptureHookRegistry and panics if it was never registered via RegisterProfCaptureHook. Enabling is separate from registering so that pipelines can reference hooks only when the corresponding instrumentation package was imported.","triggerScenarios":"Calling perf.EnableProfCaptureHook(name, opts...) (often via getJobOptions building pipeline options) with a name that has no matching RegisterProfCaptureHook call in the binary — e.g. a typo in the name or the profiling package not imported at all.","commonSituations":"Passing a profile hook name through job options/flags on a worker binary that doesn't import the package that registers the hook; renaming a hook in one place but not the option value; enabling a hook in a pipeline builder that never linked the hook's package.","solutions":["Ensure the package that calls RegisterProfCaptureHook for that exact name is imported (even blank import _ \"path/to/hook\") before enabling.","Verify the name string passed to EnableProfCaptureHook matches the registered identifier exactly.","If the name comes from a flag/job option, validate it against registered hook names before enabling.","Check that the same binary builds the pipeline and runs the worker — the registration must exist in the process that enables it."],"exampleFix":"// before\nimport (\n    \"github.com/apache/beam/sdks/go/pkg/beam\"\n    \"github.com/apache/beam/sdks/go/pkg/beam/x/hooks/perf\"\n)\nperf.EnableProfCaptureHook(\"cpuprofile\", \"out.prof\") // panics: never registered\n// after\nimport (\n    _ \"github.com/apache/beam/sdks/go/pkg/beam/x/hooks/perf/cpuhook\" // registers \"cpuprofile\"\n    \"github.com/apache/beam/sdks/go/pkg/beam/x/hooks/perf\"\n)\nperf.EnableProfCaptureHook(\"cpuprofile\", \"out.prof\")","handlingStrategy":"validation","validationCode":"// ensure the registering package is linked\nimport _ \"path/to/hook/that/registers/cpuprofile\"\n// and confirm the exact name before enabling\nconst want = \"cpuprofile\"\nperf.EnableProfCaptureHook(want, \"out.prof\")","typeGuard":null,"tryCatchPattern":"func enableProf(name string, opts ...string) (enabled bool) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"prof hook %q not registered: %v\", name, r)\n        }\n    }()\n    perf.EnableProfCaptureHook(name, opts...)\n    return true\n}","preventionTips":["Blank-import the package that registers the hook before enabling it.","Centralize hook names in constants shared by registration and enabling code.","Validate job-option/flag hook names before calling EnableProfCaptureHook.","Build the worker binary with the same imports as the pipeline constructor."],"tags":["go","apache-beam","configuration","missing-registration"],"backgroundTag":"missing-dependency","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}