BerriAI/litellm · error · ValueError
Event hook {hook} is not in the supported event hooks {suppo
Error message
Event hook {hook} is not in the supported event hooks {supported_event_hooks} What it means
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.
Source
Thrown at litellm/integrations/custom_guardrail.py:470
and the UI is expected to fall back to the global `supported_modes`
list client-side.
"""
return None
def _validate_event_hook(
self,
event_hook: GuardrailEventHooks | list[GuardrailEventHooks] | Mode | None,
supported_event_hooks: list[GuardrailEventHooks],
) -> None:
def _validate_event_hook_list_is_in_supported_event_hooks(
event_hook: list[GuardrailEventHooks] | list[str],
supported_event_hooks: list[GuardrailEventHooks],
) -> None:
for hook in event_hook:
if isinstance(hook, str):
hook = GuardrailEventHooks(hook)
if hook not in supported_event_hooks:
raise ValueError(f"Event hook {hook} is not in the supported event hooks {supported_event_hooks}")
if event_hook is None:
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)View on GitHub (pinned to 6c2dcb801b)
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
Example fix
# before (proxy_config.yaml)
guardrails:
- guardrail_name: bedrock
litellm_params:
guardrail: bedrock
mode: pre_call # not supported by this guardrail
# after
guardrails:
- guardrail_name: bedrock
litellm_params:
guardrail: bedrock
mode: during_call Defensive patterns
Strategy: validation
Validate before calling
from litellm.types.guardrails import GuardrailEventHooks
SUPPORTED = {GuardrailEventHooks.DURING_CALL} # from your guardrail subclass
def flatten(hooks) -> set:
items = hooks if isinstance(hooks, list) else [hooks]
return {GuardrailEventHooks(h) for h in items}
assert flatten(configured_hooks) <= SUPPORTED, "unsupported event hook in config" Type guard
def is_supported_hook(hook: str, supported: list[GuardrailEventHooks]) -> bool:
try:
return GuardrailEventHooks(hook) in supported
except ValueError:
return False Try / catch
try:
MyGuardrail(event_hook=["pre_call"])
except ValueError as e:
if "not in the supported event hooks" in str(e):
fix_config_and_reload()
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Event hook {event_hook} is not in the supported event hooks
- 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/1efb2b84729d4365.
Report an issue: GitHub.