René's URL Explorer Experiment


Title: design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682) · Issue #684 · developing-today/code · GitHub

Open Graph Title: design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682) · Issue #684 · developing-today/code

X Title: design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682) · Issue #684 · developing-today/code

Description: 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-serial...

Open Graph Description: 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 ...

X Description: 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 di...

Opengraph URL: https://github.com/developing-today/code/issues/684

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.112.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682)","articleBody":"## Finding\n\n`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**.\n\nEvidence (PR + current main):\n\n- PR: https://github.com/developing-today/code/pull/682 (1 commit `be7244972df90becc95b70b018ab23489c6f8163`, merge `c6ec7bd623df42909fdfa2225d249b593ad2e44c` = current main)\n- `bin/design-code-proxy.mjs:224-231` on main `c6ec7bd6`:\n\n  ```js\n  const writeHead = () => {\n    if (!clientRes.headersSent) {\n      clientRes.writeHead(localRes.statusCode || 200, {\n        ...localRes.headers,\n        'Access-Control-Allow-Origin': '*'\n      });\n    }\n  };\n  ```\n\n  `...localRes.headers` includes the backend's `content-length`.\n- `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).\n\n## Reproduced on current main (`c6ec7bd6`)\n\nRan 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:\n\n- Request: non-stream `design-code-flash` chat completion, primary returns 200 with `Content-Length: 191` and a 191-byte compact JSON body.\n- 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.\n- `JSON.parse` of the received body fails: `Expected ',' or '}' after property value in JSON at position 191`.\n- 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.\n\nThe 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.\n\n## Why it matters\n\nThis 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.\n\n## Acceptance criteria\n\n- [ ] 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).\n- [ ] 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.\n- [ ] 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.\n- [ ] Streaming success behaviour unchanged.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-23T19:41:19Z","url":"https://github.com/developing-today/code/issues/684"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:149fc97a-c5ad-3d05-abf3-b91b2ee76896
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9FB2:249987:6FFA03:96067B:6B062F2D
html-safe-nonce49f6c5770908aa94099befb63a9ff8e0473326bf53a306f563acddbefd7451e7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RkIyOjI0OTk4Nzo2RkZBMDM6OTYwNjdCOjZCMDYyRjJEIiwidmlzaXRvcl9pZCI6IjcyODI2MDE2NDA0Mzg2NzMxOTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac2bd520e35250ed69c4f5e3511eb4d7b2cbf98e3f9bc0db876ace4a3c0b45ca80
hovercard-subject-tagissue:6004342557
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/684/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7c4d275da32f23478c6b77b861b7aa8e9e1df9e30992a98327c8c0661d366bcc/developing-today/code/issues/684
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7c4d275da32f23478c6b77b861b7aa8e9e1df9e30992a98327c8c0661d366bcc/developing-today/code/issues/684
og:image:altFinding 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 ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedezren39
hostnamegithub.com
expected-hostnamegithub.com
None7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3
turbo-cache-controlno-preview
go-importgithub.com/developing-today/code git https://github.com/developing-today/code.git
octolytics-dimension-user_id26439447
octolytics-dimension-user_logindeveloping-today
octolytics-dimension-repository_id627308783
octolytics-dimension-repository_nwodeveloping-today/code
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id627308783
octolytics-dimension-repository_network_root_nwodeveloping-today/code
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release494ea0bb1e0feef734a83e2628697647755e8864
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/developing-today/code/issues/684#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdeveloping-today%2Fcode%2Fissues%2F684
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdeveloping-today%2Fcode%2Fissues%2F684
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=developing-today%2Fcode
Reloadhttps://github.com/developing-today/code/issues/684
Reloadhttps://github.com/developing-today/code/issues/684
Reloadhttps://github.com/developing-today/code/issues/684
developing-todayhttps://github.com/developing-today
codehttps://github.com/developing-today/code
Codehttps://github.com/developing-today/code
Issues1.1k (1.1k)https://github.com/developing-today/code/issues
Pull requests151 (151)https://github.com/developing-today/code/pulls
Discussionshttps://github.com/developing-today/code/discussions
Actionshttps://github.com/developing-today/code/actions
Projectshttps://github.com/developing-today/code/projects
Wikihttps://github.com/developing-today/code/wiki
Security and qualityhttps://github.com/developing-today/code/security
Insightshttps://github.com/developing-today/code/insights
https://github.com/developing-today/code
New issuehttps://github.com/login?return_to=https://github.com/developing-today/code/issues/684
New issuehttps://github.com/login?return_to=https://github.com/developing-today/code/issues/684
#685https://github.com/developing-today/code/pull/685
design-code-proxy: forwarded Content-Length truncates the re-serialized success body (PR #682)https://github.com/developing-today/code/issues/684#top
#685https://github.com/developing-today/code/pull/685
https://github.com/dezren39
https://github.com/dezren39
dezren39https://github.com/dezren39
on Oct 23, 2026https://github.com/developing-today/code/issues/684#issue-6004342557
#682https://github.com/developing-today/code/pull/682
#681https://github.com/developing-today/code/issues/681
fix(design-code-proxy): fall back on quota errors in a 200 JSON body instead of hanging (#681) #682https://github.com/developing-today/code/pull/682
#682https://github.com/developing-today/code/pull/682
github-actionshttps://github.com/apps/github-actions
dezren39https://github.com/dezren39
on Oct 23, 2026https://github.com/developing-today/code/issues/684#event-34085915386
dezren39https://github.com/dezren39
on Oct 23, 2026https://github.com/developing-today/code/issues/684#event-34087447881
Merge pull request #685 from developing-today/sweep/684-design-conten…https://github.com/developing-today/code/commit/0a405c64a908d14c68280959f49342a22ce11d0c
#685https://github.com/developing-today/code/pull/685
0a405c6https://github.com/developing-today/code/commit/0a405c64a908d14c68280959f49342a22ce11d0c
dezren39https://github.com/dezren39
completedhttps://github.com/developing-today/code/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#685https://github.com/developing-today/code/pull/685
on Oct 23, 2026https://github.com/developing-today/code/issues/684#event-34087448193
https://github.com/apps/developing-today-fleet
developing-today-fleethttps://github.com/apps/developing-today-fleet
on Nov 24, 2026https://github.com/developing-today/code/issues/684#issuecomment-7124557534
developing.today fleethttps://kaneo.security.cab
PR #685 — fix(design-code-proxy): don't forward the backend's Content-Length for re-serialized bodies (#684)https://github.com/developing-today/code/pull/685
Sign up for freehttps://github.com/signup?return_to=https://github.com/developing-today/code/issues/684
Sign in to commenthttps://github.com/login?return_to=https://github.com/developing-today/code/issues/684
dezren39https://github.com/dezren39
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.