{"record":{"id":"e0d0c259c815ad64","repo":"router-for-me/CLIProxyAPI","slug":"request-failed-with-status-d-s","errorCode":null,"errorMessage":"request failed with status %d: %s","messagePattern":"request failed with status (.+?): (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/auth/antigravity/auth.go","lineNumber":264,"sourceCode":"\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}\n\t\tif projectID == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"project id not found in loadCodeAssist or onboardUser response\")\n\t\t}\n\t\treturn projectID, nil","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/auth/antigravity/auth.go#L246-L282","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if strings.TrimSpace(accessToken) == \"\" {\n    return fmt.Errorf(\"refusing loadCodeAssist with empty token; refresh first\")\n}","typeGuard":null,"tryCatchPattern":"_, err := auth.FetchProjectID(ctx, token)\nif err != nil && strings.Contains(err.Error(), \"request failed with status\") {\n    if strings.Contains(err.Error(), \"401\") {\n        // token stale: force re-login\n    } else if strings.Contains(err.Error(), \"403\") {\n        // account not entitled: surface to user\n    } else {\n        // 5xx: retry later\n    }\n}","preventionTips":["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"],"tags":["antigravity","http-status","oauth","authorization"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}