{"record":{"id":"d7a08b46a9addf6d","repo":"apache/beam","slug":"enablehook-hook-s-not-found","errorCode":null,"errorMessage":"EnableHook: hook %s not found","messagePattern":"EnableHook: hook (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/hooks/hooks.go","lineNumber":229,"sourceCode":"\t}\n\n\tfor _, h := range r.enabledHookOrder {\n\t\topts := r.enabledHooks[h]\n\t\tr.activeHooks[h] = r.hookRegistry[h](opts)\n\t}\n}\n\n// DeserializeHooksFromOptions extracts the hook configuration information from the options and configures\n// the hooks with the supplied options.\nfunc DeserializeHooksFromOptions(ctx context.Context) {\n\tdefaultRegistry.DeserializeHooksFromOptions(ctx)\n}\n\nfunc (r *registry) EnableHook(name string, args ...string) error {\n\tr.mu.Lock()\n\tdefer r.mu.Unlock()\n\tif _, ok := r.hookRegistry[name]; !ok {\n\t\treturn errors.Errorf(\"EnableHook: hook %s not found\", name)\n\t}\n\tr.disableHook(name)\n\tr.enabledHookOrder = append(r.enabledHookOrder, name)\n\tr.enabledHooks[name] = args\n\treturn nil\n}\n\n// EnableHook enables the hook to be run for the pipeline. It will be\n// receive the supplied args when the pipeline executes.\n// Repeat calls for the same hook will overwrite previous args,\n// and move the hook to the end of the ordering.\n// Multiple options can be provided,\n// as this is necessary if a hook wants to compose behavior.\nfunc EnableHook(name string, args ...string) error {\n\treturn defaultRegistry.EnableHook(name, args...)\n}\n\nfunc (r *registry) IsEnabled(name string) (bool, []string) {","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/hooks/hooks.go#L211-L247","documentation":"hooks.EnableHook returns this error when the named hook is not present in the global hook registry. Hooks must first be registered (e.g. in a package init via RegisterHook) before they can be enabled with EnableHook(name, args...).","triggerScenarios":"Calling hooks.EnableHook(\"name\", ...) with a name that was never passed to hooks.RegisterHook, or after the hook was registered in a package that was never imported (so its init never ran).","commonSituations":"Typo in the hook name; enabling a built-in hook (e.g. capture hooks) without importing the package that registers it; registering hooks inside a test file that is not linked into the binary; removing/renaming a hook in a newer version of Beam.","solutions":["Check the exact registered name against hooks.RegisterHook calls (search the repo for RegisterHook)","Add a blank import (import _ \"path/to/hookpkg\") so the package's init registers the hook before EnableHook runs","Enable hooks through the provided helpers (e.g. hooks.EnableProfCaptureHook) which use known-good names","Verify hook name spelling and that no version upgrade renamed it"],"exampleFix":"// before\nhooks.EnableHook(\"beam.ProfCaptureHook\")\n// after\nimport _ \"github.com/apache/beam/sdks/go/pkg/beam/core/runtime/hooks\"\nhooks.EnableHook(profcapture.HookName) // name matches RegisterHook exactly","handlingStrategy":"validation","validationCode":"// check the hook exists before enabling it by scanning registered hooks\n// hooks exposes registration in init; enable via documented helper names, e.g.:\n// hooks.EnableProfCaptureHook()\n// or guard by name list maintained alongside RegisterHook calls\nknownHooks := map[string]bool{\"your.hook.name\": true} // keep in sync with RegisterHook\nif !knownHooks[name] {\n    return fmt.Errorf(\"hook %q not registered; call RegisterHook first\", name)\n}","typeGuard":null,"tryCatchPattern":"if err := hooks.EnableHook(name); err != nil {\n    if strings.Contains(err.Error(), \"not found\") {\n        // fall back: register then enable, or skip enabling\n    }\n    return err\n}","preventionTips":["Always pair RegisterHook and EnableHook names via a shared constant","Use a blank import for packages whose init registers hooks you enable","Prefer the package's helper functions (EnableProfCaptureHook, etc.) over raw name strings","After upgrading Beam, verify hook names haven't been renamed"],"tags":["go","hooks","registry","beam"],"backgroundTag":"resource-not-found","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"}