Comfy-Org/ComfyUI · error · NotImplementedError

InjectionsHook is not supported yet in ComfyUI.

Error message

InjectionsHook is not supported yet in ComfyUI.

What it means

Raised by InjectionsHook.add_hook_patches. Like ObjectPatchHook, the InjectionsHook type is declared (and round-trips through hook serialization) but applying its injections was never implemented in ComfyUI. Any attempt to register it with a ModelPatcher raises NotImplementedError before any model forward runs.

Source

Thrown at comfy/hooks.py:285

WrapperHook = TransformerOptionsHook
'''Only here for backwards compatibility, WrapperHook is identical to TransformerOptionsHook.'''

class InjectionsHook(Hook):
    def __init__(self, key: str=None, injections: list[PatcherInjection]=None,
                 hook_scope=EnumHookScope.AllConditioning):
        super().__init__(hook_type=EnumHookType.Injections)
        self.key = key
        self.injections = injections
        self.hook_scope = hook_scope

    def clone(self):
        c: InjectionsHook = super().clone()
        c.key = self.key
        c.injections = self.injections.copy() if self.injections else self.injections
        return c

    def add_hook_patches(self, model: ModelPatcher, model_options: dict, target_dict: dict[str], registered: HookGroup):
        raise NotImplementedError("InjectionsHook is not supported yet in ComfyUI.")

class HookGroup:
    '''
    Stores groups of hooks, and allows them to be queried by type.

    To prevent breaking their functionality, never modify the underlying self.hooks or self._hook_dict vars directly;
    always use the provided functions on HookGroup.
    '''
    def __init__(self):
        self.hooks: list[Hook] = []
        self._hook_dict: dict[EnumHookType, list[Hook]] = {}

    def __len__(self):
        return len(self.hooks)

    def add(self, hook: Hook):
        if hook not in self.hooks:
            self.hooks.append(hook)

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Implement the injection as a regular model forward wrapper via ModelPatcher.set_model_... APIs or patches dict instead of hooks
  2. Remove the Injections hooks from the workflow/conditioning before running in stock ComfyUI
  3. Gate your extension code on availability: skip Injections hooks when add_hook_patches is the stock unimplemented one

Example fix

# before
hook = hooks.InjectionsHook(key='block_3', injections=[inj])
# after (apply injection at patch time)
model_patcher.set_model_input_block_patch(inj_fn, block_id=3)
Defensive patterns

Strategy: type-guard

Validate before calling

from comfy.hooks import InjectionsHook
assert not isinstance(hook, InjectionsHook), 'InjectionsHook application is not implemented in ComfyUI'

Type guard

def hook_is_applicable(hook) -> bool:
    return not isinstance(hook, comfy.hooks.InjectionsHook)

Try / catch

try:
    hook.add_hook_patches(model_patcher, model_options, target_dict, group)
except NotImplementedError:
    apply_injection_via_patch_dict(model_patcher, hook.injections)

Prevention

When it happens

Trigger: Creating an InjectionsHook(key=..., injections=[...]) and letting the hook application machinery call add_hook_patches; deserializing a saved HookGroup that contains an Injections hook; extensions that build injection hooks expecting fork-level support.

Common situations: Workflows authored on forks (e.g. ones with weight-injection features) loaded in stock ComfyUI; custom nodes enumerating EnumHookType.Injections and assuming every type is live.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/ec743dbdc9c0b585. Report an issue: GitHub.