Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

fix(guardrails): keep Agent 365 missing-secret startup error readable after log redaction

yuchengf4033ab84ab9
diff --git a/litellm/proxy/guardrails/guardrail_hooks/agent_365/__init__.py b/litellm/proxy/guardrails/guardrail_hooks/agent_365/__init__.py
index 839bf5ba888..9aacdec0602 100644
--- a/litellm/proxy/guardrails/guardrail_hooks/agent_365/__init__.py
+++ b/litellm/proxy/guardrails/guardrail_hooks/agent_365/__init__.py
@@ -29,7 +29,9 @@ def initialize_guardrail(litellm_params: "LitellmParams", guardrail: "Guardrail"
if not client_id:
raise ValueError("Microsoft Agent 365: client_id is required")
if not client_secret:
- raise ValueError("Microsoft Agent 365: client_secret (or api_key) is required")
+ raise ValueError(
+ "Microsoft Agent 365: client secret is required. Set client_secret, api_key, or AGENT365_CLIENT_SECRET"
+ )
guardrail_name: Final = guardrail.get("guardrail_name")
if not guardrail_name:
diff --git a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_agent_365.py b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_agent_365.py
index 2f037418927..8245aba6d73 100644
--- a/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_agent_365.py
+++ b/tests/test_litellm/proxy/guardrails/guardrail_hooks/test_agent_365.py
@@ -7,6 +7,7 @@ import pytest
from fastapi import HTTPException
from litellm.exceptions import Timeout as LitellmTimeout
+from litellm.litellm_core_utils.secret_redaction import redact_string
from litellm.proxy._types import UserAPIKeyAuth
from litellm.proxy.guardrails.guardrail_hooks.agent_365 import (
Agent365Guardrail,
@@ -165,8 +166,9 @@ class TestInitializeGuardrail:
tenant_id="tenant-abc",
client_id="client-xyz",
)
- with pytest.raises(ValueError, match="client_secret"):
+ with pytest.raises(ValueError, match="client_secret") as exc_info:
initialize_guardrail(params, {"guardrail_name": "a365"})
+ assert redact_string(str(exc_info.value)) == str(exc_info.value)
def test_env_var_fallbacks(self, monkeypatch):
monkeypatch.delenv("AGENT365_RESOURCE_APP_ID", raising=False)