{"record":{"id":"8b5fc69955e64b0e","repo":"BerriAI/litellm","slug":"event-hook-event-hook-is-not-in-the-supported-ev","errorCode":null,"errorMessage":"Event hook {event_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":491,"sourceCode":"            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)\n        elif isinstance(event_hook, GuardrailEventHooks):\n            if event_hook not in supported_event_hooks:\n                raise ValueError(f\"Event hook {event_hook} is not in the supported event hooks {supported_event_hooks}\")\n\n    @staticmethod\n    def _get_admin_metadata(data: dict) -> dict:\n        \"\"\"Return merged admin-configured key and team metadata from the request data.\n\n        The proxy may inject admin metadata (user_api_key_metadata,\n        user_api_key_team_metadata) into either ``metadata`` or\n        ``litellm_metadata`` depending on endpoint. Check both so a caller\n        cannot shadow admin config by pre-populating the other key.\n        Key-level settings override team-level.\n        \"\"\"\n        team_meta: dict = {}\n        key_meta: dict = {}\n        for key in (\"metadata\", \"litellm_metadata\"):\n            # Defensive: an unparsed JSON-string metadata could leak past the\n            # proxy's normal parse path; don't AttributeError on .get().\n            meta = data.get(key)\n            if not isinstance(meta, dict):","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/integrations/custom_guardrail.py#L473-L509","documentation":"The single-value branch of the same validation: when event_hook is a GuardrailEventHooks enum member (not a list and not a Mode), it must be a member of supported_event_hooks or initialization raises this ValueError. It guards against wiring a guardrail into a lifecycle stage its implementation does not cover.","triggerScenarios":"Constructing or configuring a guardrail with event_hook=GuardrailEventHooks.PRE_CALL when that hook is absent from the guardrail's supported_event_hooks list. Differs from 363 only in code path: direct enum value instead of a list/Mode.","commonSituations":"Programmatic guardrail instantiation in Python (custom guardrails registered at proxy startup) with a hardcoded event_hook copied from a different integration; version upgrades that narrowed a guardrail's supported hooks.","solutions":["Set event_hook to one of the guardrail's supported hooks (check the subclass's supported_event_hooks / docs)","Pass a list containing only supported hooks if you need to express intent at init time","Update custom guardrail subclasses to declare the hooks they truly implement before assigning them"],"exampleFix":"# before\nmy_guardrail = MyGuardrail(event_hook=GuardrailEventHooks.PRE_CALL)\n\n# after\nmy_guardrail = MyGuardrail(event_hook=GuardrailEventHooks.DURING_CALL)","handlingStrategy":"type-guard","validationCode":"supported = guardrail.supported_event_hooks if hasattr(guardrail, 'supported_event_hooks') else []\nif event_hook not in supported:\n    raise ConfigError(f\"use one of {[h.value for h in supported]}\")","typeGuard":"from litellm.types.guardrails import GuardrailEventHooks\n\ndef is_valid_event_hook(value: str, supported: list[GuardrailEventHooks]) -> bool:\n    try:\n        return GuardrailEventHooks(value) in supported\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    MyGuardrail(event_hook=GuardrailEventHooks.PRE_CALL)\nexcept ValueError as e:\n    if \"not in the supported event hooks\" in str(e):\n        pick_supported_hook()\n    raise","preventionTips":["Keep a per-integration table of supported hooks and lint configs against it","Construct guardrails in one factory function that validates hooks centrally"],"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"}