{"record":{"id":"83b561065b2116a1","repo":"pulumi/pulumi","slug":"failed-to-register-hook-s-w","errorCode":null,"errorMessage":"failed to register hook %s: %w","messagePattern":"failed to register hook (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/pcl/runtime/interpreter.go","lineNumber":659,"sourceCode":"\t\tswitch node := node.(type) {\n\t\tcase *pcl.ConfigVariable:\n\t\t\t// When executing a component program, config variables are supplied as component inputs\n\t\t\t// and set before the walk; don't override them with the enclosing program's config.\n\t\t\tif i.evalContext.HasVariable(node.Name()) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif diags := i.bindConfigVariable(ctx, node); diags.HasErrors() {\n\t\t\t\treturn diags\n\t\t\t}\n\t\t\treturn nil\n\t\tcase *pcl.PulumiBlock:\n\t\t\tif err := i.enforceRequiredVersion(ctx); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\treturn nil\n\t\tcase *pcl.Hook:\n\t\t\tif err := i.registerHookNode(ctx, node); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to register hook %s: %w\", node.Name(), err)\n\t\t\t}\n\t\tcase *pcl.LocalVariable:\n\t\t\tvalue, poison, diags := i.evalContext.Evaluate(node.Definition.Value)\n\t\t\tif poison != nil {\n\t\t\t\ti.evalContext.SetVariable(node.Name(), makePoisonValue(*poison))\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tif diags.HasErrors() {\n\t\t\t\treturn diags\n\t\t\t}\n\t\t\tif err := i.setVariable(ctx, node.Name(), value); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to set variable %s: %w\", node.Name(), err)\n\t\t\t}\n\t\tcase *pcl.Resource:\n\t\t\tif err := i.registerResource(ctx, node); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to register resource %s: %w\", node.Name(), err)\n\t\t\t}\n\t\tcase *pcl.ReadResource:","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/pcl/runtime/interpreter.go#L641-L677","documentation":"During topological execution, each pcl.Hook node is registered via registerHookNode. Any failure inside that registration is wrapped with the hook's name so you know which hook failed.","triggerScenarios":"Running a program containing a Hook node whose registration fails — e.g. hook targets an unknown resource, invalid hook configuration, or the underlying monitor RPC/schema lookup fails.","commonSituations":"Misconfigured before/after hooks in PCL source; hook referencing a resource that failed or does not exist; provider schema missing the hook definition.","solutions":["Read the inner wrapped error to find the concrete cause for hook <name>.","Verify the hook's target resource exists and is registered before the hook node in the program graph.","Check the hook's configuration (operation, handler) against the provider schema and correct the PCL source."],"exampleFix":"// before\nresource myRes ... hooks: { before: [\"nonexistentHook\"] }\n// after\nhook nonexistentHook defined and attached to an existing resource","handlingStrategy":"try-catch","validationCode":"for _, h := range program.Nodes {\n    if hook, ok := h.(*pcl.Hook); ok {\n        if !hookTargetsExist(hook, resources) { return fmt.Errorf(\"hook %s target missing\", hook.Name()) }\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := interp.Run(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to register hook \") {\n        // extract hook name from the message and validate its config/targets\n    }\n}","preventionTips":["Define every hook before referencing it","Verify hook targets exist in the same program","Check hook configuration against the provider schema"],"tags":["hooks","pcl","interpreter"],"backgroundTag":"hook-registration-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}