{"record":{"id":"23e082672fde387b","repo":"router-for-me/CLIProxyAPI","slug":"decode-claude-oauth-response-unsupported-content","errorCode":null,"errorMessage":"decode Claude OAuth response: unsupported content encoding %q","messagePattern":"decode Claude OAuth response: unsupported content encoding %q","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/oauth_response.go","lineNumber":61,"sourceCode":"\tcase \"gzip\":\n\t\tgzipReader, errGzip := gzip.NewReader(bytes.NewReader(encoded))\n\t\tif errGzip != nil {\n\t\t\treturn nil, fmt.Errorf(\"decode Claude OAuth gzip response: %w\", errGzip)\n\t\t}\n\t\treader = gzipReader\n\tcase \"deflate\":\n\t\tzlibReader, errZlib := zlib.NewReader(bytes.NewReader(encoded))\n\t\tif errZlib == nil {\n\t\t\treader = zlibReader\n\t\t} else {\n\t\t\treader = flate.NewReader(bytes.NewReader(encoded))\n\t\t}\n\tcase \"br\":\n\t\treader = io.NopCloser(brotli.NewReader(bytes.NewReader(encoded)))\n\tcase \"compress\":\n\t\treader = lzw.NewReader(bytes.NewReader(encoded), lzw.MSB, 8)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"decode Claude OAuth response: unsupported content encoding %q\", encoding)\n\t}\n\tdecoded, errDecoded := io.ReadAll(reader)\n\tif errDecoded != nil {\n\t\t_ = reader.Close()\n\t\treturn nil, fmt.Errorf(\"decode Claude OAuth %s response: %w\", encoding, errDecoded)\n\t}\n\tif errClose := reader.Close(); errClose != nil {\n\t\treturn nil, fmt.Errorf(\"close Claude OAuth %s decoder: %w\", encoding, errClose)\n\t}\n\treturn decoded, nil\n}\n","sourceCodeStart":43,"sourceCodeEnd":73,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/oauth_response.go#L43-L73","documentation":"The response decoder switches over a fixed set of supported Content-Encoding values (gzip, deflate, br, compress) and rejects anything else. This error names the exact unsupported token, so the value in the message tells you what the server or an intermediary sent. It is a protocol-contract mismatch, not a transient failure.","triggerScenarios":"The OAuth response arrives with Content-Encoding: zstd (or any value outside the switch), a combined encoding such as \"gzip, br\", a case variant, or an empty/garbage header injected by a custom proxy. Only the exact lowercase single tokens gzip/deflate/br/compress are accepted.","commonSituations":"Upstream adds zstd support and starts advertising it; a developer sets a custom Accept-Encoding header (e.g. \"zstd\") on the OAuth request; proxies that append or rewrite encoding headers; case-mismatched headers from non-standard gateways.","solutions":["Set Accept-Encoding on the OAuth request to only the encodings the decoder supports (e.g. \"gzip, deflate, br\") so the server never picks zstd.","Remove custom Accept-Encoding overrides and let the client negotiate.","Extend the switch in decodeClaudeOAuthEncoding with a case for the reported encoding if your fork needs it (zstd via klauspost/compress).","Report/inspect the exact %q value in the message to identify which hop introduced it."],"exampleFix":"// before\nreq.Header.Set(\"Accept-Encoding\", \"zstd, gzip, br\")\n\n// after\nreq.Header.Set(\"Accept-Encoding\", \"gzip, deflate, br\")","handlingStrategy":"validation","validationCode":"supported := map[string]bool{\"gzip\": true, \"deflate\": true, \"br\": true, \"compress\": true}\nif enc := strings.ToLower(strings.TrimSpace(resp.Header.Get(\"Content-Encoding\"))); enc != \"\" && !supported[enc] {\n    return fmt.Errorf(\"server picked unsupported encoding %q; resend with restricted Accept-Encoding\", enc)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin Accept-Encoding to the decoders you support; never forward arbitrary encodings.","Log the %q token from the message to find which hop injects exotic encodings."],"tags":["claude","oauth","encoding","protocol"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}