{"record":{"id":"f1f26514389d8066","repo":"Comfy-Org/ComfyUI","slug":"objectpatchhook-is-not-supported-yet-in-comfyui","errorCode":null,"errorMessage":"ObjectPatchHook is not supported yet in ComfyUI.","messagePattern":"ObjectPatchHook is not supported yet in ComfyUI\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"comfy/hooks.py","lineNumber":204,"sourceCode":"        c.need_weight_init = self.need_weight_init\n        c._strength_model = self._strength_model\n        c._strength_clip = self._strength_clip\n        return c\n\nclass ObjectPatchHook(Hook):\n    def __init__(self, object_patches: dict[str]=None,\n                 hook_scope=EnumHookScope.AllConditioning):\n        super().__init__(hook_type=EnumHookType.ObjectPatch)\n        self.object_patches = object_patches\n        self.hook_scope = hook_scope\n\n    def clone(self):\n        c: ObjectPatchHook = super().clone()\n        c.object_patches = self.object_patches\n        return c\n\n    def add_hook_patches(self, model: ModelPatcher, model_options: dict, target_dict: dict[str], registered: HookGroup):\n        raise NotImplementedError(\"ObjectPatchHook is not supported yet in ComfyUI.\")\n\nclass AdditionalModelsHook(Hook):\n    '''\n    Hook responsible for telling model management any additional models that should be loaded.\n\n    Note, value of hook_scope is ignored and is treated as AllConditioning.\n    '''\n    def __init__(self, models: list[ModelPatcher]=None, key: str=None):\n        super().__init__(hook_type=EnumHookType.AdditionalModels)\n        self.models = models\n        self.key = key\n\n    def clone(self):\n        c: AdditionalModelsHook = super().clone()\n        c.models = self.models.copy() if self.models else self.models\n        c.key = self.key\n        return c\n","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy/hooks.py#L186-L222","documentation":"Raised by ObjectPatchHook.add_hook_patches. The ObjectPatchHook class and its EnumHookType.ObjectPatch enum value exist for hook serialization/deserialization compatibility (e.g. hooks saved in workflows), but ComfyUI's execution engine never implemented applying object patches via hooks. Attempting to register one against a ModelPatcher always raises NotImplementedError.","triggerScenarios":"Constructing an ObjectPatchHook(object_patches={...}) and calling add_hook_patches on it (directly or through HookGroup registration during conditioning application). Loading a workflow that serialized an object-patch hook from a fork/extension that does support it (e.g. ComfyUI-Lightning-style weight hooks) into stock ComfyUI.","commonSituations":"Users moving workflows between ComfyUI forks and stock ComfyUI; extension authors assuming all EnumHookType values are functional; deserializing hook payloads whose type index maps to ObjectPatch.","solutions":["Replace ObjectPatchHook usage with model patching via ModelPatcher.add_object_patch applied directly at the node level","If the workflow came from another fork, install that fork/extension or strip the object-patch hooks before loading","If you are building hook support, implement the logic in your own Hook subclass rather than calling the stock add_hook_patches"],"exampleFix":"# before\nhook = hooks.ObjectPatchHook(object_patches={'diffusion_model.blocks.0': patch})\ngroup.add(hook)  # later raises NotImplementedError\n# after\nmodel_patcher.add_object_patch('diffusion_model.blocks.0', patch)","handlingStrategy":"type-guard","validationCode":"from comfy import hooks\nhook = hooks.ObjectPatchHook(...)\nif type(hook).add_hook_patches is hooks.ObjectPatchHook.add_hook_patches:\n    raise RuntimeError('ObjectPatchHook is unimplemented; use model_patcher.add_object_patch')","typeGuard":"def hook_is_applicable(hook) -> bool:\n    return not isinstance(hook, comfy.hooks.ObjectPatchHook)","tryCatchPattern":"try:\n    hook.add_hook_patches(model_patcher, model_options, target_dict, group)\nexcept NotImplementedError:\n    model_patcher.add_object_patch(key, patch)","preventionTips":["Prefer ModelPatcher.add_object_patch over hook-based object patches in stock ComfyUI","Strip hook types you do not control from imported workflows"],"tags":["hooks","not-implemented","model-patching","compatibility"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}