summaryrefslogtreecommitdiff
path: root/plugins/security-guidance/hooks/llm.py
diff options
context:
space:
mode:
authorMohamed Hegazy <mhegazy@anthropic.com>2026-10-28 10:32:00 +0000
committerClaude <noreply@anthropic.com>2026-10-28 10:32:00 +0000
commitaa67609219635b7cac03bea3f22aed16381bc274 (patch)
tree18f104a362c16cafb57ccaf5732029507655a9c3 /plugins/security-guidance/hooks/llm.py
parentf8c5e7a1dcb71b10cb74586224b5401f3de5db28 (diff)
security-guidance: treat a blank ANTHROPIC_BASE_URL as unsetfix/sg-blank-base-url
A set but empty value left the request URL as /v1/messages, so urllib raised and every Stop, push and single-shot commit review failed. The SDK and Claude Code read a blank value as the default endpoint; the plugin now does too.
Diffstat (limited to 'plugins/security-guidance/hooks/llm.py')
-rw-r--r--plugins/security-guidance/hooks/llm.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/plugins/security-guidance/hooks/llm.py b/plugins/security-guidance/hooks/llm.py
index 468d9e6d..d3983f35 100644
--- a/plugins/security-guidance/hooks/llm.py
+++ b/plugins/security-guidance/hooks/llm.py
@@ -195,10 +195,13 @@ def _anthropic_base_url() -> str:
Honors ANTHROPIC_BASE_URL (the convention the Anthropic SDK and CC itself
use) so customers behind an LLM gateway (LiteLLM, Bifrost, self-hosted
Anthropic-compatible proxy) can route the plugin's reviews through their
- gateway. Defaults to https://api.anthropic.com. Always returns a string
- with no trailing slash so callers can safely append /v1/messages etc.
+ gateway. Defaults to https://api.anthropic.com, also when the variable is
+ set but blank, which is how the SDK and CC read it. Always returns a
+ string with no trailing slash so callers can safely append /v1/messages
+ etc.
"""
- return os.environ.get("ANTHROPIC_BASE_URL", "https://api.anthropic.com").rstrip("/")
+ base = os.environ.get("ANTHROPIC_BASE_URL", "").strip()
+ return (base or "https://api.anthropic.com").rstrip("/")
# ── Windows certificate store with an entry OpenSSL cannot read ──────────