{"record":{"id":"1efb2b84729d4365","repo":"BerriAI/litellm","slug":"event-hook-hook-is-not-in-the-supported-event-ho","errorCode":null,"errorMessage":"Event hook {hook} is not in the supported event hooks {supported_event_hooks}","messagePattern":"Event hook (.+?) is not in the supported event hooks (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/integrations/custom_guardrail.py","lineNumber":470,"sourceCode":"        and the UI is expected to fall back to the global `supported_modes`\n        list client-side.\n        \"\"\"\n        return None\n\n    def _validate_event_hook(\n        self,\n        event_hook: GuardrailEventHooks | list[GuardrailEventHooks] | Mode | None,\n        supported_event_hooks: list[GuardrailEventHooks],\n    ) -> None:\n        def _validate_event_hook_list_is_in_supported_event_hooks(\n            event_hook: list[GuardrailEventHooks] | list[str],\n            supported_event_hooks: list[GuardrailEventHooks],\n        ) -> None:\n            for hook in event_hook:\n                if isinstance(hook, str):\n                    hook = GuardrailEventHooks(hook)\n                if hook not in supported_event_hooks:\n                    raise ValueError(f\"Event hook {hook} is not in the supported event hooks {supported_event_hooks}\")\n\n        if event_hook is None:\n            return\n        if isinstance(event_hook, str):\n            event_hook = GuardrailEventHooks(event_hook)\n        if isinstance(event_hook, list):\n            _validate_event_hook_list_is_in_supported_event_hooks(event_hook, supported_event_hooks)\n        elif isinstance(event_hook, Mode):\n            tag_values_flat: Final[list] = []\n            for v in event_hook.tags.values():\n                if isinstance(v, list):\n                    tag_values_flat.extend(v)\n                else:\n                    tag_values_flat.append(v)\n            _validate_event_hook_list_is_in_supported_event_hooks(tag_values_flat, supported_event_hooks)\n            if event_hook.default:\n                default_list = event_hook.default if isinstance(event_hook.default, list) else [event_hook.default]\n                _validate_event_hook_list_is_in_supported_event_hooks(default_list, supported_event_hooks)","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/custom_guardrail.py#L452-L488","documentation":"During guardrail initialization, _validate_event_hook_list_is_in_supported_event_hooks checks every hook in the event_hook list (or in a Mode's flattened tag/default values) against the list of hooks the guardrail subclass declares support for. Any hook not present in supported_event_hooks raises this ValueError, preventing a guardrail from being registered for a lifecycle stage it cannot actually handle.","triggerScenarios":"Passing event_hook=['pre_call', 'post_call'] (or a mode string/mode object whose tags expand to those) to a guardrail whose supported_event_hooks only includes e.g. ['during_call', 'pre_morph_call', 'post_morph_call']. String values are coerced via GuardrailEventHooks(hook), so an unknown literal string raises from the enum constructor, and a known-but-unsupported hook raises this message.","commonSituations":"Copy-pasting guardrail yaml config (mode: pre_call) between guardrails with different hook support; upgrading litellm where a guardrail's supported hooks changed; passing Mode objects with tags on OSS where tag-based selection differs.","solutions":["Read the guardrail subclass's supported_event_hooks (documented per integration) and restrict event_hook/mode to those values","Fix proxy_config.yaml: change the guardrail's mode to one the integration supports (e.g. 'during_call' instead of 'pre_call')","If you own the subclass, extend supported_event_hooks and implement the corresponding hook methods"],"exampleFix":"# before (proxy_config.yaml)\nguardrails:\n  - guardrail_name: bedrock\n    litellm_params:\n      guardrail: bedrock\n      mode: pre_call   # not supported by this guardrail\n\n# after\nguardrails:\n  - guardrail_name: bedrock\n    litellm_params:\n      guardrail: bedrock\n      mode: during_call","handlingStrategy":"validation","validationCode":"from litellm.types.guardrails import GuardrailEventHooks\n\nSUPPORTED = {GuardrailEventHooks.DURING_CALL}  # from your guardrail subclass\n\ndef flatten(hooks) -> set:\n    items = hooks if isinstance(hooks, list) else [hooks]\n    return {GuardrailEventHooks(h) for h in items}\n\nassert flatten(configured_hooks) <= SUPPORTED, \"unsupported event hook in config\"","typeGuard":"def is_supported_hook(hook: str, supported: list[GuardrailEventHooks]) -> bool:\n    try:\n        return GuardrailEventHooks(hook) in supported\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    MyGuardrail(event_hook=[\"pre_call\"])\nexcept ValueError as e:\n    if \"not in the supported event hooks\" in str(e):\n        fix_config_and_reload()\n    raise","preventionTips":["Derive guardrail config mode values from each integration's documented supported hooks","Validate yaml guardrail blocks in CI against the supported hook list before deploy","After litellm upgrades, re-check supported_event_hooks of custom guardrails"],"tags":["guardrail","config","event-hooks","validation"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}