{"record":{"id":"0565b4604e410f2a","repo":"router-for-me/CLIProxyAPI","slug":"read-claude-oauth-s-response-w","errorCode":null,"errorMessage":"read Claude OAuth %s response: %w","messagePattern":"read Claude OAuth (.+?) response: %w","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/claude/anthropic_auth.go","lineNumber":252,"sourceCode":"\tif errRequest != nil {\n\t\treturn nil, fmt.Errorf(\"create Claude OAuth %s request: %w\", label, errRequest)\n\t}\n\tapplyClaudeOAuthAxiosHeaders(req)\n\treq.Header.Set(\"Authorization\", \"Bearer \"+accessToken)\n\treq.Header.Set(\"Cache-Control\", \"no-cache\")\n\n\tresp, errDo := o.httpClient.Do(req)\n\tif errDo != nil {\n\t\treturn nil, fmt.Errorf(\"fetch Claude OAuth %s: %w\", label, errDo)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"failed to close Claude OAuth %s response body: %v\", label, errClose)\n\t\t}\n\t}()\n\tbody, errRead := readClaudeOAuthResponseBody(resp)\n\tif errRead != nil {\n\t\treturn nil, fmt.Errorf(\"read Claude OAuth %s response: %w\", label, errRead)\n\t}\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {\n\t\treturn nil, fmt.Errorf(\"fetch Claude OAuth %s failed with status %d\", label, resp.StatusCode)\n\t}\n\treturn body, nil\n}\n\n// FetchOAuthProfile retrieves the account identity associated with an OAuth access token.\nfunc (o *ClaudeAuth) FetchOAuthProfile(ctx context.Context, accessToken string) (*OAuthProfile, error) {\n\tbody, errFetch := o.fetchOAuthControlPlaneJSON(ctx, ProfileURL, accessToken, \"profile\")\n\tif errFetch != nil {\n\t\treturn nil, errFetch\n\t}\n\tvar profile OAuthProfile\n\tif errUnmarshal := json.Unmarshal(body, &profile); errUnmarshal != nil {\n\t\treturn nil, fmt.Errorf(\"parse Claude OAuth profile response: %w\", errUnmarshal)\n\t}\n\tif strings.TrimSpace(profile.Account.UUID) == \"\" {","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/claude/anthropic_auth.go#L234-L270","documentation":"Returned by ClaudeAuth.fetchOAuthControlPlaneJSON when reading the OAuth response body fails, wrapping the error from readClaudeOAuthResponseBody. That helper goes beyond io.ReadAll: because the request advertises Accept-Encoding: gzip, compress, deflate, br, it manually decodes Content-Encoding layers (gzip via compress/gzip, deflate via zlib with flate fallback, br via brotli, compress via lzw). So this error is either a truncated body (unexpected EOF) or a failed decode of a declared content encoding (e.g. corrupt gzip stream, or an encoding the switch does not support).","triggerScenarios":"Connection reset mid-body; server sending a Content-Encoding the decoder cannot handle (custom or mislabeled encoding yields 'unsupported content encoding'); corrupt compressed payload from an intermediary that re-encodes the body but keeps the original Content-Encoding header.","commonSituations":"Antivirus/SSL-inspection appliances recompressing responses inconsistently; flaky networks truncating compressed streams; rare server-side encoding bugs. If the message contains 'unsupported content encoding', an intermediary is re-writing headers.","solutions":["Read the wrapped message: 'unexpected EOF' → network truncation, retry; 'unsupported content encoding' or 'decode ... gzip/brotli' → intermediary re-encoding, inspect the proxy chain","Bypass or disable response re-compression on the intercepting middlebox","Retry the auth flow; single truncated responses are transient"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"profile, err := auth.FetchOAuthProfile(ctx, token)\nif err != nil {\n    msg := err.Error()\n    if strings.Contains(msg, \"unexpected EOF\") || strings.Contains(msg, \"decode Claude OAuth\") {\n        // truncated or undecodable compressed body: retry once, then inspect proxy chain\n        time.Sleep(time.Second)\n        profile, err = auth.FetchOAuthProfile(ctx, token)\n    }\n    if err != nil { return err }\n}","preventionTips":["Disable response re-compression on SSL-inspecting middleboxes in front of the proxy","Treat decode failures on gzip/br bodies as a sign an intermediary is rewriting responses"],"tags":["claude","network","compression","io","oauth"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}