mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-28 01:32:17 +00:00
fix(proxy): reject nested guardrail patch body
This commit is contained in:
parent
1af7a403c6
commit
a5dce43aba
2 changed files with 17 additions and 0 deletions
|
|
@ -1215,6 +1215,8 @@ class ApplyGuardrailResponse(BaseModel):
|
|||
|
||||
|
||||
class PatchGuardrailRequest(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
guardrail_name: str | None = None
|
||||
litellm_params: BaseLitellmParams | None = None
|
||||
guardrail_info: dict[str, Any] | None = None
|
||||
|
|
|
|||
|
|
@ -80,6 +80,21 @@ MOCK_PATCH_REQUEST = PatchGuardrailRequest(
|
|||
)
|
||||
|
||||
|
||||
def test_patch_guardrail_request_rejects_create_body_shape():
|
||||
"""Do not silently accept the nested POST /guardrails request body."""
|
||||
from pydantic import ValidationError
|
||||
|
||||
with pytest.raises(ValidationError, match="extra_forbidden"):
|
||||
PatchGuardrailRequest.model_validate(
|
||||
{
|
||||
"guardrail": {
|
||||
"guardrail_name": "nested-name",
|
||||
"litellm_params": {},
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_prisma_client(mocker):
|
||||
"""Mock Prisma client for testing"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue