BerriAI/litellm · error · ValueError
Event hook {event_hook} is not in the supported event hooks
Error message
Event hook {event_hook} is not in the supported event hooks {supported_event_hooks} What it means
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.
Source
Thrown at litellm/integrations/custom_guardrail.py:491
return
if isinstance(event_hook, str):
event_hook = GuardrailEventHooks(event_hook)
if isinstance(event_hook, list):
_validate_event_hook_list_is_in_supported_event_hooks(event_hook, supported_event_hooks)
elif isinstance(event_hook, Mode):
tag_values_flat: Final[list] = []
for v in event_hook.tags.values():
if isinstance(v, list):
tag_values_flat.extend(v)
else:
tag_values_flat.append(v)
_validate_event_hook_list_is_in_supported_event_hooks(tag_values_flat, supported_event_hooks)
if event_hook.default:
default_list = event_hook.default if isinstance(event_hook.default, list) else [event_hook.default]
_validate_event_hook_list_is_in_supported_event_hooks(default_list, supported_event_hooks)
elif isinstance(event_hook, GuardrailEventHooks):
if event_hook not in supported_event_hooks:
raise ValueError(f"Event hook {event_hook} is not in the supported event hooks {supported_event_hooks}")
@staticmethod
def _get_admin_metadata(data: dict) -> dict:
"""Return merged admin-configured key and team metadata from the request data.
The proxy may inject admin metadata (user_api_key_metadata,
user_api_key_team_metadata) into either ``metadata`` or
``litellm_metadata`` depending on endpoint. Check both so a caller
cannot shadow admin config by pre-populating the other key.
Key-level settings override team-level.
"""
team_meta: dict = {}
key_meta: dict = {}
for key in ("metadata", "litellm_metadata"):
# Defensive: an unparsed JSON-string metadata could leak past the
# proxy's normal parse path; don't AttributeError on .get().
meta = data.get(key)
if not isinstance(meta, dict):View on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before my_guardrail = MyGuardrail(event_hook=GuardrailEventHooks.PRE_CALL) # after my_guardrail = MyGuardrail(event_hook=GuardrailEventHooks.DURING_CALL)
Defensive patterns
Strategy: type-guard
Validate before calling
supported = guardrail.supported_event_hooks if hasattr(guardrail, 'supported_event_hooks') else []
if event_hook not in supported:
raise ConfigError(f"use one of {[h.value for h in supported]}") Type guard
from litellm.types.guardrails import GuardrailEventHooks
def is_valid_event_hook(value: str, supported: list[GuardrailEventHooks]) -> bool:
try:
return GuardrailEventHooks(value) in supported
except ValueError:
return False Try / catch
try:
MyGuardrail(event_hook=GuardrailEventHooks.PRE_CALL)
except ValueError as e:
if "not in the supported event hooks" in str(e):
pick_supported_hook()
raise Prevention
- Keep a per-integration table of supported hooks and lint configs against it
- Construct guardrails in one factory function that validates hooks centrally
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Event hook {hook} is not in the supported event hooks {suppo
- Setting tag-based guardrails is only available in litellm-en
- Invalid environment: {environment}. Please use one of the fo
- bucket_name must be provided for S3 destination
- Export format '{self.export_format}' not supported. Use 'par
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/8b5fc69955e64b0e.
Report an issue: GitHub.