router-for-me/CLIProxyAPI · error
read response: %w
Error message
read response: %w
What it means
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.
Source
Thrown at internal/auth/antigravity/auth.go:260
}
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Accept", "*/*")
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", userAgent)
resp, errDo := o.httpClient.Do(req)
if errDo != nil {
return "", fmt.Errorf("execute request: %w", errDo)
}
defer func() {
if errClose := resp.Body.Close(); errClose != nil {
log.Errorf("antigravity loadCodeAssist: close body error: %v", errClose)
}
}()
bodyBytes, errRead := io.ReadAll(resp.Body)
if errRead != nil {
return "", fmt.Errorf("read response: %w", errRead)
}
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
return "", fmt.Errorf("request failed with status %d: %s", resp.StatusCode, strings.TrimSpace(string(bodyBytes)))
}
var loadResp map[string]any
if errDecode := json.Unmarshal(bodyBytes, &loadResp); errDecode != nil {
return "", fmt.Errorf("decode response: %w", errDecode)
}
projectID := extractCloudaicompanionProject(loadResp)
if projectID == "" {
projectID, err = o.OnboardUser(ctx, accessToken, defaultAntigravityTierID(loadResp))
if err != nil {
return "", err
}View on GitHub (pinned to 78f0c4079e)
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
Defensive patterns
Strategy: retry
Try / catch
if _, err := auth.FetchProjectID(ctx, token); err != nil {
if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
return err
}
time.Sleep(2 * time.Second)
_, err = auth.FetchProjectID(ctx, token)
if err != nil { return err }
} Prevention
- Give the login flow a context with headroom beyond expected round-trip time
- Treat mid-body read failures as transient; retry once before escalating
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- failed to read token response: %w
- failed to read refresh response: %w
- antigravity token exchange: create request: %w
- antigravity token exchange: execute request: %w
- antigravity token exchange: read response: %w
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/55807306bd9085ab.
Report an issue: GitHub.