{"record":{"id":"ae59aac20246571f","repo":"apache/beam","slug":"enableheapcapturehook-s-not-registered","errorCode":null,"errorMessage":"EnableHeapCaptureHook: %s not registered","messagePattern":"EnableHeapCaptureHook: (.+?) not registered","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/x/hooks/perf/perf.go","lineNumber":219,"sourceCode":"\nvar heapCaptureHookRegistry = make(map[string]CaptureHookFactory)\nvar enabledHeapCaptureHooks []string\n\n// RegisterHeapCaptureHook registers a CaptureHookFactory for the\n// supplied identifier. It panics if the same identifier is\n// registered twice.\nfunc RegisterHeapCaptureHook(name string, c CaptureHookFactory) {\n\tif _, exists := heapCaptureHookRegistry[name]; exists {\n\t\tpanic(fmt.Sprintf(\"RegisterHeapCaptureHook: %s registered twice\", name))\n\t}\n\theapCaptureHookRegistry[name] = c\n}\n\n// EnableHeapCaptureHook actives a registered heap profile capture hook for a given pipeline.\nfunc EnableHeapCaptureHook(name string, opts ...string) {\n\t_, exists := heapCaptureHookRegistry[name]\n\tif !exists {\n\t\tpanic(fmt.Sprintf(\"EnableHeapCaptureHook: %s not registered\", name))\n\t}\n\n\tenc := hooks.Encode(name, opts)\n\n\tfor i, h := range enabledHeapCaptureHooks {\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\tenabledHeapCaptureHooks[i] = enc\n\t\t\thooks.EnableHook(\"heap\", enabledHeapCaptureHooks...)\n\t\t\treturn\n\t\t}\n\t}\n\n\tenabledHeapCaptureHooks = append(enabledHeapCaptureHooks, enc)\n\thooks.EnableHook(\"heap\", enabledHeapCaptureHooks...)\n}\n","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/x/hooks/perf/perf.go#L201-L237","documentation":"EnableHeapCaptureHook panics when the requested heap hook name is not present in heapCaptureHookRegistry, i.e. RegisterHeapCaptureHook was never called for it in this process. Enabling an unregistered hook would silently produce no profile data, so the library fails loudly instead.","triggerScenarios":"Calling perf.EnableHeapCaptureHook(name, opts...) (commonly from getJobOptions reading pipeline/job options) with a name no registration provided — typo, missing import of the registering package, or stale option value after a rename.","commonSituations":"Enabling heap profiling via flags on workers built without the heap hook package; renaming the hook in code but not in launch scripts/CLI; copy-pasted option strings from a different pipeline.","solutions":["Blank-import the package that registers the heap hook before enabling it.","Ensure the name string exactly matches the registered identifier.","Update launch scripts/flags after hook renames; validate names against the registry.","Confirm the registering package is linked into the same binary that enables the hook."],"exampleFix":"// before\nperf.EnableHeapCaptureHook(\"heapprofile\", \"out\") // panics: not registered\n// after\nimport _ \"github.com/apache/beam/sdks/go/pkg/beam/x/hooks/perf/heaphook\" // registers \"heapprofile\"\nperf.EnableHeapCaptureHook(\"heapprofile\", \"out\")","handlingStrategy":"validation","validationCode":"import _ \"path/to/hook/that/registers/heapprofile\"\nconst heapHookName = \"heapprofile\" // must match the registered identifier\nperf.EnableHeapCaptureHook(heapHookName, \"out\")","typeGuard":null,"tryCatchPattern":"func enableHeap(name string, opts ...string) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"heap hook %q not registered: %v\", name, r)\n        }\n    }()\n    perf.EnableHeapCaptureHook(name, opts...)\n}","preventionTips":["Ensure the registering package is imported into the binary that enables the hook.","Keep hook names in shared constants, not ad-hoc flag strings.","Update CI/deploy flags after any hook rename.","Fail fast at startup by validating configured hook names against registrations."],"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"}