Problem: when GetByKey fails with anything other than not-found or
overloaded, the API key middlewares answer 500 "Failed to validate API
key" without logging the cause. Two client-side conditions end up there:
- The client goes away while the key is being looked up (connection
closed after the body was sent, or an HTTP/2 stream reset). net/http
cancels the request context, the cache/DB lookup returns
context.Canceled, and a pure client disconnect is recorded as an
internal server error. A key that is not in the 15 s L1 cache always
reaches Redis/Postgres, so infrequent clients hit this regularly.
- A key that is not valid UTF-8. Postgres rejects the parameter
(invalid byte sequence, SQLSTATE 22021), which surfaces as 500 instead
of 401. Generated and custom keys are always ASCII, so such a key can
never match.
Fix: GetByKey treats non-UTF-8 keys as not found before any cache or DB
access. Both middlewares (OpenAI/Anthropic and Google) end the request
with 499 when the request context is already done, which the ops error
logger already skips as a client-closed request; any other lookup error
is now logged before the 500.
Test: api_key_auth_test.go drives both middlewares with a lookup that is
cancelled mid-flight (499) and with a plain repository error (500), and
sends a non-UTF-8 x-api-key (401). api_key_service_cache_test.go checks
that a non-UTF-8 key never reaches the repository. All three fail
without the fix.
proxyOpenAIWSHTTPBridgeTurn built its upstream request without staging the
converged Codex fingerprint IDs, unlike Forward and forwardOpenAIPassthrough.
The bridge therefore sent different device-fingerprint headers than the HTTP
paths for the same account, and when the client sent no prompt_cache_key the
request carried no session_id at all, so upstream prompt-cache routing was
effectively random and multi-turn requests rarely hit the cache.
Stage the IDs (and rewrite client_metadata) the same way
forwardOpenAIPassthrough does, clearing any stale IDs first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
Gateway handlers such as Anthropic /v1/messages read the whole request body
before they know the model or account. The HTTP server sets no ReadTimeout
(large bodies may legitimately take long), so a stalled upload held the
handler until the client gave up, and every read failure then surfaced as a
generic 400 "Failed to read request body" with no diagnostics.
- Add server.request_body_idle_timeout (default 60s, 0 disables). A body
read that receives no bytes for that long fails with 408. Each Read re-arms
the deadline, so total upload time is not limited and handler pauses are
not counted. HTTP/2 deadlines are armed only during a Read; HTTP/1 keeps
one armed while the body is unfinished so net/http's own drain of an
unread body cannot hang an early error response.
- Classify body read failures in the shared reader: read timeout (408),
client disconnect (499), truncated body, decode errors and size limit.
Other failures keep the stable 400 message. Map 408 to DEADLINE_EXCEEDED
in Google-format errors.
- Log payload-free diagnostics for every gateway and middleware body read
failure: kind, protocol, declared length, encoding, bytes received and
read duration.
handleFailoverExhausted returned a fixed 413 for
IsOpenAIRequestBodyTooLarge() before reaching the generic error-passthrough
rule lookup further down, so a rule configured with error_codes [413] could
never match on this path. The service layer already returns the same
failover sentinel ahead of applyErrorPassthroughRule, so both layers
short-circuit and the rule vocabulary silently excludes 413.
Extract the existing rule application into
applyOpenAIFailoverPassthroughRule and call it first inside the body-limit
branch (and reuse it for the generic branch). Failover on 413 is left
intact: different accounts can front proxies with different body limits, so
switching may still succeed. The rule only decides the client-facing
response once failover is exhausted.
This matters for clients that treat 413 as retryable. Codex CLI maps a
non-2xx HTTP status to CodexErr::UnexpectedStatus, whose is_retryable()
returns true, and retries the sampling request up to stream_max_retries
(default 5) times. When the payload can never fit, every retry is wasted
work, and an operator has no supported way to signal "do not retry". Mapping
the same upstream 413 to 400 makes Codex map it to InvalidRequest, which is
not retryable, so it fails fast.
Tests cover the override on both unary and started-stream paths, the
unchanged built-in 413 when no rule matches, and skip_monitoring.
Fixes frontend-security on main for two new high advisories:
- GHSA-83rm-6c8r-g728 (vue-i18n / @intlify/* srcdoc XSS): v9 and v10
are end of life and will not be patched, so move vue-i18n and
@intlify/message-compiler to 11.4.16.
- GHSA-qr28-fpjm-wq7f (decode-uri-component quadratic DoS): add a
pnpm override to >=0.5.1; its API and types are unchanged.
vue-i18n 11 requires Node >= 22, so CI and release workflows move from
Node 20 to Node 24, matching the Docker build image.
JIT message compilation is always on since v10, so the obsolete
__INTLIFY_JIT_COMPILATION__ define is removed; the build still has no
new Function. SubscriptionPlanCard spec asserted raw keys that v9's
runtime build returned; it now asserts the rendered test messages.
go-sdk v1.4.1 fixes GO-2026-4773 (cross-site tool execution) and
GO-2026-4770 (null Unicode JSON parsing), which fail govulncheck.
v1.4.1 also adds transport-level cross-origin and Content-Type checks
that would reject requests Authenticate already accepts:
- trust the same allowed origins in the SDK's CrossOriginProtection so
CORS-allowlisted browser clients are not refused with 403;
- accept application/json with parameters (e.g. charset) by normalizing
the header, while still refusing non-JSON bodies with 415.
Signed client IDs are now about 200 characters. Show them on one line on
the consent page and in the connection list, with the full value in the
title. The random part leads, so truncated IDs still differ.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registration was capped at 1000 pending clients site-wide while the limit
per IP was 10 per minute, so one address could exhaust the cap and block
every new MCP client.
- Issue client IDs as HMAC-signed tokens carrying the client name,
redirect URI digests and grant types. Registration writes nothing;
rows are created only when a user approves a client, so there is no
shared capacity to exhaust.
- Persist the signing key in security_secrets via the existing
get-or-create helper, cached lock-free, so instances share it.
- Drop mcp_oauth_clients from migration 249 and keep the client name on
each grant. Prune expired grants on authorization, before the owner
row is locked.
- Fix an unchecked type assertion in managementmcp tests flagged by
golangci-lint v2.14.0.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Replace the cube icon with the official MCP logo in the sidebar and on
the MCP connection and consent pages.
- Show the MCP entry only when the deployment enables MCP (mcp_enabled).
- Explain that administrator write grants always need TOTP verification,
and add MCP OAuth to the audit log auth-method filter.
- Remove the unreferenced screenshots and their .gitignore exceptions (L6).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Reject JSON-RPC batches and non-object bodies before the SDK; return each
tool result once as text and bound the encoded payload (H1).
- Enable MCP only when MCP_PUBLIC_URL is set; drop the frontend URL fallback
and expose a read-only mcp_enabled public setting (M1).
- Expire never-authorized clients after 24h, cap pending registrations
globally, aggregate MCP IP limits by IPv6 /64, and limit registration
bodies to 4 KiB (M2).
- Revoke MCP grants with revoke-all-sessions and always require step-up for
administrator write grants (M3).
- Rate limit /api/v1/mcp per IP before authentication and write last_used_at
at most once per minute (M4).
- Persistently revoke grants when an account is disabled or demoted, derive
result redaction from SensitiveCredentialKeys, allowlist browser sessions
for step-up, audit every MCP read, reject invisible characters in
client_name, and document site-root-only deployment (L1-L5, L7).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ChatGPT OAuth upstream may answer with SSE but omit the Content-Type
header. Fall back to bodyHasSSEFraming for OAuth accounts in
handleNonStreamingResponsePassthrough, matching handleNonStreamingResponse,
and add a regression test covering both passthrough and non-passthrough.
Co-authored-by: SipengXie2024 <184713193+SipengXie2024@users.noreply.github.com>