{"record":{"id":"9d564201a327c954","repo":"pulumi/pulumi","slug":"the-pulumi-cli-does-not-support-error-hooks-pleas-9d5642","errorCode":null,"errorMessage":"The Pulumi CLI does not support error hooks. Please update the Pulumi CLI.","messagePattern":"The Pulumi CLI does not support error hooks\\. Please update the Pulumi CLI\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/python/lib/pulumi/runtime/resource.py","lineNumber":1433,"sourceCode":"                # Delete hooks can't be anonymous\n                if hook_type in (\"before_delete\", \"after_delete\"):\n                    raise ValueError(\n                        \"Delete resource hooks must be ResourceHook instances\"\n                    )\n                if not callable(hook):\n                    raise ValueError(\"Resource hook must be a Callable or ResourceHook\")\n                name = f\"{name_prefix}_{hook_type}_{i}\"\n                hook = ResourceHook(name, hook)\n            # Wait for the hook registration to complete\n            await hook._registered\n            getattr(proto, hook_type).append(hook.name)\n\n    on_error_hooks_list: list[ErrorHook] = getattr(hooks, \"on_error\", []) or []\n    if on_error_hooks_list:\n        if not monitor_supports_feature(\n            resource_pb2.RESOURCE_MONITOR_FEATURE_ERROR_HOOKS\n        ):\n            raise Exception(\n                \"The Pulumi CLI does not support error hooks. Please update the Pulumi CLI.\"\n            )\n\n        for error_hook in on_error_hooks_list:\n            if not isinstance(error_hook, ErrorHook):\n                raise ValueError(\"Error hooks must be ErrorHook instances\")\n            await error_hook._registered\n            proto.on_error.append(error_hook.name)\n\n    return proto\n\n\ndef register_resource_hook(hook: \"ResourceHook\") -> asyncio.Future[None]:\n    async def do_register() -> None:\n        callbacks = await _get_callbacks()\n        if callbacks is None:\n            raise Exception(\"No callback server registered.\")\n        return callbacks.register_resource_hook(hook)","sourceCodeStart":1415,"sourceCodeEnd":1451,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/python/lib/pulumi/runtime/resource.py#L1415-L1451","documentation":"Error hooks (on_error list in Hooks) require the resource monitor to support RESOURCE_MONITOR_FEATURE_ERROR_HOOKS. Hooks were configured but the connected CLI/monitor lacks the feature, so the SDK raises before registering.","triggerScenarios":"Passing Hooks(on_error=[...]) on a resource while running against a Pulumi CLI without error hook support.","commonSituations":"Newest SDK APIs with an older engine; CI runners with stale pulumi binaries.","solutions":["Upgrade the Pulumi CLI to a version supporting error hooks","Remove the on_error hooks until the CLI is updated","Handle errors via standard exception handling in the program instead"],"exampleFix":"// before\nHooks(on_error=[ErrorHook(\"eh\", fn)])\n// after\n# after upgrading pulumi CLI\nHooks(on_error=[ErrorHook(\"eh\", fn)])  # supported","handlingStrategy":"validation","validationCode":"# only attach on_error hooks when CLI supports error hooks\nhooks_arg = Hooks(on_error=err_hooks) if cli_supports_error_hooks() else None\nres = MyResource(\"n\", opts=ResourceOptions(hooks=hooks_arg))","typeGuard":null,"tryCatchPattern":"try:\n    res = MyResource(\"n\", opts=ResourceOptions(hooks=Hooks(on_error=err_hooks)))\nexcept Exception as e:\n    if \"error hooks\" in str(e):\n        print(\"CLI does not support error hooks; upgrade or use try/except\")\n    raise","preventionTips":["Check Pulumi release notes for error hook minimum CLI version","Standardize CLI versions before enabling error hooks repo-wide"],"tags":["python","pulumi-cli","error-hooks","version-compatibility"],"backgroundTag":"pulumi-cli-feature-unsupported","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}