router-for-me/CLIProxyAPI · error
request failed with status %d: %s
Error message
request failed with status %d: %s
What it means
Returned by AntigravityAuth.FetchProjectID when the loadCodeAssist endpoint answers with a non-2xx status. The message includes the status code and the full trimmed response body, so the upstream Google error (usually a JSON block with a 'message' field) is embedded verbatim. Common causes are an invalid/expired OAuth access token (401), missing cloudaicompanion API entitlements (403), or a malformed request (400).
Source
Thrown at internal/auth/antigravity/auth.go:264
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
}
if projectID == "" {
return "", fmt.Errorf("project id not found in loadCodeAssist or onboardUser response")
}
return projectID, nilView on GitHub (pinned to 78f0c4079e)
Solutions
- Read the embedded body: a 401 with 'Invalid Credentials' means the access token is stale — re-run the antigravity login flow to mint fresh credentials
- A 403 with 'permission denied' on cloudaicompanion.googleapis.com means the account lacks entitlement — enable Gemini code assist or use an account that has it
- A 5xx is transient: wait and retry the auth flow
- Verify the system clock; skewed clocks can invalidate freshly issued tokens
Defensive patterns
Strategy: try-catch
Validate before calling
if strings.TrimSpace(accessToken) == "" {
return fmt.Errorf("refusing loadCodeAssist with empty token; refresh first")
} Try / catch
_, err := auth.FetchProjectID(ctx, token)
if err != nil && strings.Contains(err.Error(), "request failed with status") {
if strings.Contains(err.Error(), "401") {
// token stale: force re-login
} else if strings.Contains(err.Error(), "403") {
// account not entitled: surface to user
} else {
// 5xx: retry later
}
} Prevention
- Refresh the access token immediately before calling FetchProjectID
- Keep system clocks synchronized (NTP) so fresh tokens are not rejected
- Confirm the account has Gemini/Antigravity code-assist entitlement before scripting login
When it happens
Trigger: Calling FetchProjectID with an access token that expired between refresh and this call (401); a Google account without Gemini/Antigravity code-assist access enabled (403); upstream 5xx during a Google incident.
Common situations: Stale token file under auths/ where the refresh token flow succeeded but the new token was rejected; GoogleWorkspace accounts with the Gemini for Workspace app policy disabled; regional blocks on cloudcode-pa.googleapis.com.
Related errors
- antigravity token exchange: request failed: status %d
- antigravity token exchange: request failed: status %d: %s
- antigravity userinfo: request failed: status %d
- antigravity userinfo: request failed: status %d: %s
- http %d: %s
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/e0d0c259c815ad64.
Report an issue: GitHub.