{"record":{"id":"55807306bd9085ab","repo":"router-for-me/CLIProxyAPI","slug":"read-response-w","errorCode":null,"errorMessage":"read response: %w","messagePattern":"read response: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/antigravity/auth.go","lineNumber":260,"sourceCode":"\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+accessToken)\n\treq.Header.Set(\"Accept\", \"*/*\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", userAgent)\n\n\tresp, errDo := o.httpClient.Do(req)\n\tif errDo != nil {\n\t\treturn \"\", fmt.Errorf(\"execute request: %w\", errDo)\n\t}\n\tdefer func() {\n\t\tif errClose := resp.Body.Close(); errClose != nil {\n\t\t\tlog.Errorf(\"antigravity loadCodeAssist: close body error: %v\", errClose)\n\t\t}\n\t}()\n\n\tbodyBytes, errRead := io.ReadAll(resp.Body)\n\tif errRead != nil {\n\t\treturn \"\", fmt.Errorf(\"read response: %w\", errRead)\n\t}\n\n\tif resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {\n\t\treturn \"\", fmt.Errorf(\"request failed with status %d: %s\", resp.StatusCode, strings.TrimSpace(string(bodyBytes)))\n\t}\n\n\tvar loadResp map[string]any\n\tif errDecode := json.Unmarshal(bodyBytes, &loadResp); errDecode != nil {\n\t\treturn \"\", fmt.Errorf(\"decode response: %w\", errDecode)\n\t}\n\n\tprojectID := extractCloudaicompanionProject(loadResp)\n\n\tif projectID == \"\" {\n\t\tprojectID, err = o.OnboardUser(ctx, accessToken, defaultAntigravityTierID(loadResp))\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/antigravity/auth.go#L242-L278","documentation":"Returned by AntigravityAuth.FetchProjectID when io.ReadAll on the loadCodeAssist response body fails after a successful HTTP exchange. The request already reached the server and headers were received; the failure happens mid-body. Typical causes are the connection dropping during transfer, the server closing early, or the request context being cancelled while the body streams.","triggerScenarios":"Connection reset between response headers and body completion on cloudcode-pa.googleapis.com; ctx cancelled while io.ReadAll is draining the body; intermediary (proxy/ALB) truncating the response.","commonSituations":"Flaky mobile or containerized networking; aggressive proxy idle timeouts that cut long responses; a parent context with a short deadline passed into the OAuth refresh flow that includes FetchProjectID.","solutions":["Retry the authentication flow: FetchProjectID is called during login/refresh, and a transient truncation resolves on the next attempt","Check whether the parent context has a deadline shorter than the full HTTP round trip and lengthen or remove it","If persistent, capture the underlying error (unexpected EOF vs context.Canceled) and inspect the proxy chain for response truncation"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := auth.FetchProjectID(ctx, token); err != nil {\n    if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {\n        return err\n    }\n    time.Sleep(2 * time.Second)\n    _, err = auth.FetchProjectID(ctx, token)\n    if err != nil { return err }\n}","preventionTips":["Give the login flow a context with headroom beyond expected round-trip time","Treat mid-body read failures as transient; retry once before escalating"],"tags":["antigravity","network","io","transient"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}