Skip to content

fix(gateway): 补修 #473/#474 合入后仍在的问题 - #486

Merged
caigee-cmd merged 3 commits into
mainfrom
fix/followup-473-474-gzip-heartbeat
Nov 11, 2026
Merged

caigee-cmd merged 3 commits into
mainfrom
fix/followup-473-474-gzip-heartbeat

Conversation

@caigee-cmd

Copy link
Copy Markdown
Owner

Follow-up to the pre-merge review notes on #473 and #474, which landed on main (and shipped in v0.7.28 / v0.7.29) without these patches. This PR does not revert either feature.

#474 gzip / error shape

  • Decompressing past the inflated size limit now returns a distinct ErrInflatedBodyTooLarge (mapped to 413 request body too large) instead of io.LimitReader's silent EOF. A JSON decoder therefore sees "body too large", not a syntax error from a truncated object, and cannot continue with a cut-off body.
  • POST /v1/messages body-decoding failures (unsupported encoding, corrupt gzip, over-limit inflate) use the Anthropic error envelope this endpoint already returns for other request errors, not the OpenAI shape from writeRequestBodyError.

#473 heartbeat / headers / metrics / changelog

  • Account and provider are known as soon as the executor picks a route, which is before the wait for the upstream response head. A StreamRouteHint on the request context lets setStreamHeaders include X-Qoder-Account, X-CLI2API-Account, and X-CLI2API-Provider before the heartbeat's WriteHeader. Holding the heartbeat until ChatStreamProxy returns would defeat its purpose.
  • After Adopt(), a heartbeat write failure (clientGone()) or a canceled request context is recorded as canceled. The handler no longer writes streaming first and does not treat a disconnect during the heartbeat wait as a normal stream open.
  • The v0.7.28 changelog (and the heartbeat comments) no longer say this feature avoids a slow upload. Heartbeat starts only after the request body has been read; it covers waiting for the upstream response head / prefill. An unreleased fragment describes the follow-up behavior.

Tests

  • Inflated over-limit: hard error, including incomplete JSON at the cap; exact-limit bodies still succeed.
  • /v1/messages unknown encoding and corrupt gzip keep the Anthropic error shape.
  • Live stream with an early heartbeat commit still exposes account/provider headers.
  • Client disconnect during the heartbeat wait is logged as canceled, never as streaming.

Does not merge, release, or deploy.

caigee-cmd and others added 3 commits November 11, 2026 14:37
…eat headers

Reject decompressed bodies that exceed the inflated size limit instead of
silently truncating them. Keep /v1/messages body-decoding errors in the
Anthropic envelope. Send account/provider headers with an early heartbeat
commit, and record a disconnect during that wait as canceled rather than
a normal stream open. Correct the changelog wording that said heartbeat
avoids a slow upload.
… cap

Restore the shipped v0.7.28 changelog wording; the correction already lives
in the unreleased fragment. Cover a decompressed body that fills the inflate
cap exactly when read in small chunks, and note that a client disconnect
during the heartbeat wait does not bind the session.
Pick up the failover, check-in, and WorkBuddy changes that landed after this branch. chat.go auto-merged; the stream route hint calls stay in place.
@caigee-cmd
caigee-cmd merged commit 1990c04 into main Nov 11, 2026
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant