From 66a7811b89c2abd0f6f3184684050dd3da8dc8ce Mon Sep 17 00:00:00 2001 From: CHX606 <1461530475@qq.com> Date: Thu, 1 Oct 2026 19:49:34 -0700 Subject: [PATCH] fix(guardrails): validate masked parameter mappings --- litellm/proxy/guardrails/guardrail_endpoints.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/litellm/proxy/guardrails/guardrail_endpoints.py b/litellm/proxy/guardrails/guardrail_endpoints.py index aee6260b5e2..afe7a2acfbf 100644 --- a/litellm/proxy/guardrails/guardrail_endpoints.py +++ b/litellm/proxy/guardrails/guardrail_endpoints.py @@ -266,7 +266,7 @@ async def list_guardrails_v2( number_of_asterisks=4, ) masked_litellm_params = ( - BaseLitellmParams(**masked_litellm_params_dict) if masked_litellm_params_dict else None + BaseLitellmParams.model_validate(masked_litellm_params_dict) if masked_litellm_params_dict else None ) guardrail_configs.append( GuardrailInfoResponse( @@ -307,7 +307,9 @@ async def list_guardrails_v2( number_of_asterisks=4, ) masked_in_memory_litellm_params_typed = ( - BaseLitellmParams(**masked_in_memory_litellm_params) if masked_in_memory_litellm_params else None + BaseLitellmParams.model_validate(masked_in_memory_litellm_params) + if masked_in_memory_litellm_params + else None ) guardrail_configs.append( GuardrailInfoResponse( @@ -1369,7 +1371,9 @@ async def get_guardrail_info(guardrail_id: str): unmasked_length=4, number_of_asterisks=4, ) - masked_litellm_params = BaseLitellmParams(**masked_litellm_params_dict) if masked_litellm_params_dict else None + masked_litellm_params = ( + BaseLitellmParams.model_validate(masked_litellm_params_dict) if masked_litellm_params_dict else None + ) return GuardrailInfoResponse( guardrail_id=result.get("guardrail_id"),