{"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":473,"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":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/integrations/custom_guardrail.py#L455-L491","documentation":"CustomGuardrail validates its event_hook configuration (single value, list, or Mode) against the hooks the concrete guardrail actually supports via _validate_event_hook_list_is_in_supported_event_hooks. Any hook in the list that is not in supported_event_hooks raises a ValueError naming the offending hook and the allowed set. This variant comes from the list/Mode branch of validation.","triggerScenarios":"Configuring mode: [pre_call, during_call] on a guardrail whose supported_event_hooks is only ['pre_call']; a Mode object whose tags or default list reference hooks the guardrail does not implement; passing hook names as strings that resolve to unsupported GuardrailEventHooks values.","commonSituations":"Copy-pasting guardrail config between guardrails with different hook support; upgrading a guardrail that dropped a hook; enabling 'post_call_error' style modes on a pre-call-only guardrail.","solutions":["Check the guardrail class's supported_event_hooks (its docs or constructor) and set mode/event_hook to a supported value like pre_call","Remove unsupported entries from the config list or Mode tags/defaults","If you own the guardrail, implement the missing hook and add it to supported_event_hooks"],"exampleFix":"# before (config.yaml)\nlitellm_settings:\n  guardrails:\n    - guardrail_name: my_pre_call_guard\n      mode: [pre_call, post_call_error]  # ValueError: post_call_error not supported\n\n# after\nlitellm_settings:\n  guardrails:\n    - guardrail_name: my_pre_call_guard\n      mode: pre_call","handlingStrategy":"validation","validationCode":"supported = {'pre_call', 'during_call', 'post_call'}\nrequested = [h.value if hasattr(h, 'value') else h for h in (mode if isinstance(mode, list) else [mode])]\nbad = [h for h in requested if h not in supported]\nif bad:\n    raise ConfigError(f'unsupported event hooks for this guardrail: {bad}; allowed: {sorted(supported)}')","typeGuard":"def is_supported_hook(hook, supported_event_hooks: list[GuardrailEventHooks]) -> bool:\n    h = GuardrailEventHooks(hook) if isinstance(hook, str) else hook\n    return h in supported_event_hooks","tryCatchPattern":"except ValueError as e:\n    if 'not in the supported event hooks' in str(e):\n        fail config load with the supported list from the message\n    raise","preventionTips":["Validate guardrail config in CI before deploy (load YAML, instantiate guardrails)","Keep one canonical mapping of guardrail -> supported modes","Re-validate config after upgrading guardrail packages"],"tags":["guardrail","validation","event-hooks","configuration","litellm"],"backgroundTag":"invalid-config-value","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}