mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
Remove dead code in purview_dlp: _resolve_user_id_for_blocking never returns falsy
The method either returns a non-empty trusted user id or raises HTTPException, so the 'if not user_id' guards in async_pre_call_hook and async_post_call_success_hook were unreachable. Tighten the return type to str and drop the dead checks to make the fail-closed behavior explicit. Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
parent
212815dd5a
commit
93e4f4aea9
1 changed files with 1 additions and 5 deletions
|
|
@ -257,7 +257,7 @@ class MicrosoftPurviewDLPGuardrail(PurviewGuardrailBase, CustomGuardrail):
|
|||
self,
|
||||
data: Dict[str, Any],
|
||||
user_api_key_dict: Any,
|
||||
) -> Optional[str]:
|
||||
) -> str:
|
||||
"""Resolve user ID for blocking (pre_call / post_call) DLP hooks.
|
||||
|
||||
Uses only trusted proxy-authenticated sources (``_resolve_trusted_user_id``).
|
||||
|
|
@ -307,8 +307,6 @@ class MicrosoftPurviewDLPGuardrail(PurviewGuardrailBase, CustomGuardrail):
|
|||
) -> Optional[Dict[str, Any]]:
|
||||
"""Check user prompt against Purview DLP policies before LLM call."""
|
||||
user_id = self._resolve_user_id_for_blocking(data, user_api_key_dict)
|
||||
if not user_id:
|
||||
return data
|
||||
|
||||
prompt_text: Optional[str] = None
|
||||
is_text_completion = call_type in ("text_completion", "atext_completion")
|
||||
|
|
@ -360,8 +358,6 @@ class MicrosoftPurviewDLPGuardrail(PurviewGuardrailBase, CustomGuardrail):
|
|||
this hook for requests that have a streaming iterator hook defined.
|
||||
"""
|
||||
user_id = self._resolve_user_id_for_blocking(data, user_api_key_dict)
|
||||
if not user_id:
|
||||
return response
|
||||
|
||||
parts = self._completion_response_text_parts(response)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue