GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682) · Issue #684 · developing-today/code

design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682) #684

New issue
Copy link
New issue
Copy link
Closed
#685
Closed
design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682)#684
#685
Copy link
Assignees
dezren39
Labels
app/design-code-proxybin/design-code-proxy.mjs fleet proxykind/bugSomething isn't working (prefixed form of the classic bug label)

Description

@dezren39
dezren39
opened on Oct 23, 2026
Issue body actions

Finding

bin/design-code-proxy.mjs's writeHead() helper (added by PR #682, fixing #681) forwards the backend's Content-Length header verbatim, but the non-stream success path then sends a different body than the backend sent: it re-serializes the parsed JSON with the model field rewritten and pretty-printing (JSON.stringify(json, null, 2)). Whenever the backend sets Content-Length — the normal behaviour of a buffered JSON HTTP server — the forwarded length is the length of the backend's original (usually compact) body, so the client reads exactly that many bytes and gets truncated, unparseable JSON.

Evidence (PR + current main):

  • PR: fix(design-code-proxy): fall back on quota errors in a 200 JSON body instead of hanging (#681) #682 (1 commit be7244972df90becc95b70b018ab23489c6f8163, merge c6ec7bd623df42909fdfa2225d249b593ad2e44c = current main)

  • bin/design-code-proxy.mjs:224-231 on main c6ec7bd6:

    const writeHead = () => {
      if (!clientRes.headersSent) {
        clientRes.writeHead(localRes.statusCode || 200, {
          ...localRes.headers,
          'Access-Control-Allow-Origin': '*'
        });
      }
    };

    ...localRes.headers includes the backend's content-length.

  • bin/design-code-proxy.mjs:270-272: json.model = modelId; writeHead(); clientRes.end(JSON.stringify(json, null, 2)); — the body actually sent is longer than the backend's body in essentially every case (pretty-printing alone guarantees it; the model rewrite usually changes the length too).

Reproduced on current main (c6ec7bd6)

Ran the real bin/design-code-proxy.mjs with stub backends (same stub pattern as bin/design-code-proxy.test.mjs), except the primary stub sets an explicit Content-Length on its compact JSON success body, as a standard HTTP server does:

  • Request: non-stream design-code-flash chat completion, primary returns 200 with Content-Length: 191 and a 191-byte compact JSON body.
  • Proxy response: status 200, content-length: 191 forwarded — but the re-serialized pretty body is longer, so the client receives exactly 191 bytes, ending mid-JSON.
  • JSON.parse of the received body fails: Expected ',' or '}' after property value in JSON at position 191.
  • Control: the PR's own test suite passes 5/5 on the same main — its stubs never set Content-Length (Node then answers chunked), which is why the suite cannot see this. The sibling in-repo proxies (muse/codex/agy) also happen to answer chunked (they set only Content-Type), so the default local chain may not trigger it today; any backend that sets Content-Length — e.g. the real Antigravity LS backend this proxy fronts, or any Go/Rust/framework server — truncates every successful non-stream response through this proxy.

The streaming path uses the same writeHead() spread, so the same mismatch applies in principle there too (each SSE chunk's model is rewritten, changing lengths); SSE backends normally answer chunked, so the verified harm is the non-stream path.

Why it matters

This turns the proxy's success path into corrupted output for a whole class of standards-compliant backends: the client gets a 200 with a syntactically invalid JSON body instead of the completion. It sits in the exact helper PR #682 introduced, and the new test file's stubs mask it by never sending the one header that triggers it.

Acceptance criteria

  • A non-stream success response from a backend that sets Content-Length arrives at the client complete and parseable, with model rewritten to the design model id (no truncation).
  • The proxy does not forward a stale Content-Length for any body it re-serializes (drop the header and let Node frame the response, or set it to the actual sent length); headers for bodies forwarded byte-for-byte (the non-JSON catch branch) stay correct.
  • Regression test: a stub backend that sets an explicit Content-Length on its JSON success body, asserting the client receives the full model-rewritten body; the existing 5 tests in bin/design-code-proxy.test.mjs still pass.
  • Streaming success behaviour unchanged.

Activity

  1. github-actions
    assigned
    dezren39
    on Oct 23, 2026
  2. dezren39
    added a commit that references this issue on Oct 23, 2026

    Merge pull request #685 from developing-today/sweep/684-design-conten…

    0a405c6
  3. dezren39
    closed this as completedin #685on Oct 23, 2026
  4. developing-today-fleet commented on Nov 24, 2026

    @developing-today-fleet
    developing-today-fleetBot
    on Nov 24, 2026 – with developing.today fleet
    Contributor
    More actions

    AUDIT-7 Lane 2 slice 3 — closing evidence. Verified against the issue body and merged implementation PR(s):

    • PR #685 — fix(design-code-proxy): don't forward the backend's Content-Length for re-serialized bodies (#684) (merged 2026-10-23)

    The issue had zero comments in the fresh pre-action read; this comment records the missing close evidence.

  5. dezren39
    added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    app/design-code-proxybin/design-code-proxy.mjs fleet proxy
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @dezren39
    dezren39

Labels

app/design-code-proxybin/design-code-proxy.mjs fleet proxykind/bugSomething isn't working (prefixed form of the classic bug label)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.