BerriAI/litellm · error · ValueError
Event hook is not in the supported event hooks
Error message
Event hook {hook} is not in the supported event hooks {supported_event_hooks} What it means
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.
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
Example fix
# before (config.yaml)
litellm_settings:
guardrails:
- guardrail_name: my_pre_call_guard
mode: [pre_call, post_call_error] # ValueError: post_call_error not supported
# after
litellm_settings:
guardrails:
- guardrail_name: my_pre_call_guard
mode: pre_call Defensive patterns
Strategy: validation
Validate before calling
supported = {'pre_call', 'during_call', 'post_call'}
requested = [h.value if hasattr(h, 'value') else h for h in (mode if isinstance(mode, list) else [mode])]
bad = [h for h in requested if h not in supported]
if bad:
raise ConfigError(f'unsupported event hooks for this guardrail: {bad}; allowed: {sorted(supported)}') Type guard
def is_supported_hook(hook, supported_event_hooks: list[GuardrailEventHooks]) -> bool:
h = GuardrailEventHooks(hook) if isinstance(hook, str) else hook
return h in supported_event_hooks Try / catch
except ValueError as e:
if 'not in the supported event hooks' in str(e):
fail config load with the supported list from the message
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Event hook is not in the supported event hooks
- Cisco AI Defense guardrail: invalid rule definition
- CodeInterpreterInterception: no sandbox available. Provide…
- max_bytes_per_call must be >= 0 (0 disables the cap…
- RSS feed missing element
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/1efb2b84729d4365.
Report an issue: GitHub.
Appendix: source
Thrown at litellm/integrations/custom_guardrail.py:473
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 77b7c6c40c)