Title: bug: AI Gateway returns 500 "invalid JSON request body" for zstd-compressed request bodies (Copilot CLI >= 1.0.106, VS Code Copilot Chat) · Issue #32208 · coder/coder · GitHub
Open Graph Title: bug: AI Gateway returns 500 "invalid JSON request body" for zstd-compressed request bodies (Copilot CLI >= 1.0.106, VS Code Copilot Chat) · Issue #32208 · coder/coder
X Title: bug: AI Gateway returns 500 "invalid JSON request body" for zstd-compressed request bodies (Copilot CLI >= 1.0.106, VS Code Copilot Chat) · Issue #32208 · coder/coder
Description: Is there an existing issue for this? I have searched the existing issues Current Behavior GitHub Copilot clients send request bodies compressed with Content-Encoding: zstd. AI Gateway does not decompress them, tries to parse the compress...
Open Graph Description: Is there an existing issue for this? I have searched the existing issues Current Behavior GitHub Copilot clients send request bodies compressed with Content-Encoding: zstd. AI Gateway does not deco...
X Description: Is there an existing issue for this? I have searched the existing issues Current Behavior GitHub Copilot clients send request bodies compressed with Content-Encoding: zstd. AI Gateway does not deco...
Opengraph URL: https://github.com/coder/coder/issues/32208
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bug: AI Gateway returns 500 \"invalid JSON request body\" for zstd-compressed request bodies (Copilot CLI >= 1.0.106, VS Code Copilot Chat)","articleBody":"### Is there an existing issue for this?\n\n- [x] I have searched the existing issues\n\n### Current Behavior\n\nGitHub Copilot clients send request bodies compressed with `Content-Encoding: zstd`. AI Gateway does not decompress them, tries to parse the compressed bytes as JSON, and answers HTTP 500 for every request. Because interception creation fails, nothing is recorded under AI Gateway > Sessions.\n\nVerified (same prompt through AI Gateway Proxy, only the CLI version changed):\n- Copilot CLI 1.0.102, 1.0.104, 1.0.105: work\n- Copilot CLI 1.0.106, 1.0.107, 1.0.108, 1.0.110, 1.0.112: fail with 500 (client retries 5x, then \"500 Internal Server Error\")\n\nBoth routes are affected: `/v1/messages` (Claude models) and `/responses` (GPT models).\n\nThe Copilot CLI bundled in VS Code (agent host, user agent `copilot/1.0.108-0 ... client/vscode-agent-host`, VS Code 1.146.0 / Copilot Chat 0.74.0 via Coder Remote) fails with the same gateway error, so VS Code Copilot Chat sessions are never recorded either.\n\nRequest headers captured with CODER_AI_GATEWAY_PROXY_DUMP_DIR (Copilot CLI 1.0.112, secrets redacted) include `Content-Encoding: zstd` with a binary body.\n\nRelated client-compatibility fix for context: #28494.\n\nNote: an AI coding assistant helped with the investigation.\n\n### Relevant Log Output\n\n```shell\ncoderd.ai-gateway.pool: failed to create interceptor path=/copilot-individual/v1/messages\n error= unmarshal request body:\n github.com/coder/coder/v2/aibridge/provider.(*Copilot).CreateInterceptor copilot.go:191\n - messages invalid JSON request body:\n github.com/coder/coder/v2/aibridge/intercept/messages.NewRequestPayload reqpayload.go:105\ncoderd: POST /api/v2/ai-gateway/copilot-individual/v1/messages status_code=500\n user_agent=\"copilot/1.0.108-0 (linux unknown) term/unknown client/vscode-agent-host\"\ncoderd.aibridgeproxyd: received error response from aibridged provider=copilot-individual status=500\n response_body=\"failed to create \\\"/copilot-individual/v1/messages\\\" interceptor\"\n# same failure on POST /api/v2/ai-gateway/copilot-individual/responses\n```\n\n### Expected Behavior\n\nAI Gateway honours `Content-Encoding` on request bodies (at least zstd; ideally also gzip, br and deflate): decompress before parsing, record the session as usual, and forward the decompressed body upstream without the `Content-Encoding` header (or re-encode it).\n\nCurrent workaround: a small pass-through service set as CODER_AI_GATEWAY_PROXY_TARGET that decompresses the body and forwards everything else unchanged. With it, Copilot CLI 1.0.112 works and sessions are recorded.\n\n### Steps to Reproduce\n\n1. Enable AI Gateway and AI Gateway Proxy (CODER_AI_GATEWAY_PROXY_ENABLED=true plus MITM CA cert/key) and add a `copilot` provider (https://api.individual.githubcopilot.com).\n2. In a workspace: `export HTTPS_PROXY=http://coder:\u003ccoder-token>@\u003ccoderd-host>:8888` and `export NODE_EXTRA_CA_CERTS=\u003cAI Gateway Proxy CA pem>`; log in with `copilot login`.\n3. Install Copilot CLI 1.0.112: `VERSION=1.0.112 PREFIX=$HOME/.local bash \u003c(curl -fsSL https://gh.io/copilot-install)`, then `COPILOT_AUTO_UPDATE=false copilot -p \"say hi\"`.\n Result: \"Request failed due to a transient API error\" x5, then \"500 Internal Server Error\"; no session appears.\n4. Repeat with `VERSION=1.0.105`: works and the session appears.\n\n### Environment\n\n- Host OS: Alpine Linux (arm64) micro-VM (smolvm) on macOS; workspaces: Ubuntu (Docker)\n- Coder version: v2.39.1+6e6ab22\n\n### Additional Context\n\n_No response_","author":{"url":"https://github.com/rhobit24","@type":"Person","name":"rhobit24"},"datePublished":"2026-11-15T17:43:27Z","url":"https://github.com/coder/coder/issues/32208"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:f92f0218-ccfe-69ba-8c13-32fa0be40426 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 954E:212AFB:FFDEC:15CCFB:6B042DB6 |
| html-safe-nonce | aad2dc6a10575ea96153d40107aa488e4cd4293d68bc26328bb8c08f63181a70 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NTRFOjIxMkFGQjpGRkRFQzoxNUNDRkI6NkIwNDJEQjYiLCJ2aXNpdG9yX2lkIjoiMjA0MjAxNzkyMzIyODUxMTY3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 69de658a31c32d55eaf049d539d39448427647b0eb071b767f12a5b1418d9375 |
| hovercard-subject-tag | issue:6407300043 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/coder/coder/32208/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ea05c763efdc7762c4c2b64c6abd1b4d544b29fd3c70d5d957d70a8ecf986e39/coder/coder/issues/32208 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ea05c763efdc7762c4c2b64c6abd1b4d544b29fd3c70d5d957d70a8ecf986e39/coder/coder/issues/32208 |
| og:image:alt | Is there an existing issue for this? I have searched the existing issues Current Behavior GitHub Copilot clients send request bodies compressed with Content-Encoding: zstd. AI Gateway does not deco... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rhobit24 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b7a1d2b9101496921b08579fbee988d014345aef2f5bd660d1f8c7332d81560e |
| turbo-cache-control | no-preview |
| go-import | github.com/coder/coder git https://github.com/coder/coder.git |
| octolytics-dimension-user_id | 95932066 |
| octolytics-dimension-user_login | coder |
| octolytics-dimension-repository_id | 440752086 |
| octolytics-dimension-repository_nwo | coder/coder |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 440752086 |
| octolytics-dimension-repository_network_root_nwo | coder/coder |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c3dd496c3da6ea6b77e69c09279d2b81604654f1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width