From f4033ab84ab9fd22e01cceb92cdf08733ce7bd7a Mon Sep 17 00:00:00 2001 From: yucheng Date: Thu, 10 Sep 2026 08:08:33 +0000 Subject: [PATCH] fix(guardrails): keep Agent 365 missing-secret startup error readable after log redaction Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../proxy/guardrails/guardrail_hooks/agent_365/__init__.py | 4 +++- .../proxy/guardrails/guardrail_hooks/test_agent_365.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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)