fix(guardrails): add 'block' as valid on_violation value in BaseLitellmParams (#23685)

Guardrail configs loaded from the database can have on_violation='block'
(a natural choice for "block the request"). The current Pydantic schema
only accepts Literal["warn", "end_session"], causing a validation error:

  Input should be 'warn' or 'end_session' [type=literal_error, input_value='block', ...]

Add 'block' to the Literal type so existing configs with on_violation='block'
are accepted instead of crashing the proxy on startup.

Fixes #23624

Co-authored-by: NIK-TIGER-BILL <nik.zamuldinov@gmail.com>
This commit is contained in:
Zamuldinov Nikita 2026-03-16 18:37:06 +03:00 • committed by GitHub
parent 3dccdde9c8
commit 47d238b228
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -656,9 +656,9 @@ class BaseLitellmParams(
default=None,
description="For /v1/realtime sessions: automatically close the session after this many guardrail violations.",
)
on_violation: Optional[Literal["warn", "end_session"]] = Field(
on_violation: Optional[Literal["warn", "end_session", "block"]] = Field(
default=None,
description="For /v1/realtime sessions: 'warn' speaks the violation message and continues; 'end_session' speaks the message and closes the connection.",
description="For /v1/realtime sessions: 'warn' speaks the violation message and continues; 'end_session' speaks the message and closes the connection. 'block' rejects the request (same as the default guardrail behaviour).",
)
realtime_violation_message: Optional[str] = Field(
default=None,