fix(proxy): mention caller-supplied credentials in anthropic passthrough 401 message

Operators can intentionally run without proxy-side Anthropic credentials
and have each caller forward their own key. The enriched 401 message now
lists sending a valid Anthropic credential in the request headers as a
remediation alongside configuring proxy-side credentials, so callers with
an invalid or expired key are not directed only at proxy configuration.
This commit is contained in:
mateo-berri 2026-06-12 06:38:31 +00:00
parent 61118b0eba
commit 3445d16b6c
No known key found for this signature in database

View file

@ -655,11 +655,12 @@ async def anthropic_proxy_route(
except ProxyException as e:
if auth_header is None and e.code == "401":
e.message = (
"No Anthropic credentials found on the proxy. Set the ANTHROPIC_API_KEY "
"environment variable (or ANTHROPIC_AUTH_TOKEN for OAuth) on the proxy, "
"or configure Anthropic pass-through credentials. The incoming request "
"headers were forwarded to Anthropic as-is and the request failed with "
f"error: {e.message}"
"No Anthropic credentials found on the proxy, so the incoming "
"request headers were forwarded to Anthropic as-is and were "
"rejected. Either set the ANTHROPIC_API_KEY environment variable "
"(or ANTHROPIC_AUTH_TOKEN for OAuth) on the proxy, configure "
"Anthropic pass-through credentials, or send a valid Anthropic "
f"credential in the request headers. Original error: {e.message}"
)
raise e