router-for-me/CLIProxyAPI · error
create request: %w
Error message
create request: %w
What it means
Returned by AntigravityAuth.FetchProjectID when http.NewRequestWithContext rejects the POST target for the loadCodeAssist call. The URL is built from the constants APIEndpoint (https://cloudcode-pa.googleapis.com) and APIVersion (v1internal), so parsing fails only if those constants were changed to a malformed URL, or if the passed ctx is nil (NewRequestWithContext panics/errors on nil URL parse results). It is a construction-time guard, not a network error.
Source
Thrown at internal/auth/antigravity/auth.go:241
return email, nil
}
// FetchProjectID retrieves the project ID for the authenticated user via loadCodeAssist
func (o *AntigravityAuth) FetchProjectID(ctx context.Context, accessToken string) (string, error) {
userAgent := o.shortUserAgent()
loadReqBody := map[string]any{
"metadata": antigravityLoadCodeAssistMetadata(),
}
rawBody, errMarshal := json.Marshal(loadReqBody)
if errMarshal != nil {
return "", fmt.Errorf("marshal request body: %w", errMarshal)
}
endpointURL := fmt.Sprintf("%s/%s:loadCodeAssist", APIEndpoint, APIVersion)
req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpointURL, strings.NewReader(string(rawBody)))
if err != nil {
return "", fmt.Errorf("create request: %w", err)
}
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 {View on GitHub (pinned to 78f0c4079e)
Solutions
- Check the %w cause: if it mentions 'missing protocol scheme' or 'invalid control character', fix the APIEndpoint/APIVersion constants or the URL-building format string
- Ensure the caller passes a non-nil context (context.Background() at minimum)
- Rebuild and retry; no network state is involved
Example fix
// before APIEndpoint = "cloudcode-pa.googleapis.com" // no scheme: create request fails // after APIEndpoint = "https://cloudcode-pa.googleapis.com"
Defensive patterns
Strategy: validation
Validate before calling
if _, errParse := url.Parse(fmt.Sprintf("%s/%s:loadCodeAssist", antigravity.APIEndpoint, antigravity.APIVersion)); errParse != nil || ctx == nil {
return fmt.Errorf("invalid loadCodeAssist request parameters")
} Try / catch
projectID, err := auth.FetchProjectID(ctx, token)
if err != nil {
var urlErr *url.Error
if errors.As(err, &urlErr) && strings.Contains(urlErr.Err.Error(), "parse") {
log.Errorf("endpoint constant misconfigured: %v", err)
}
return err
} Prevention
- Never pass a nil context; default to context.Background()
- Validate overridden endpoint constants with url.Parse in a unit test
When it happens
Trigger: Calling FetchProjectID(ctx, token) where ctx is nil, or after overriding internal/auth/antigravity/constants.go APIEndpoint/APIVersion with a string that url.Parse rejects (bad scheme, control characters).
Common situations: Forking the proxy to point cloudcode-pa.googleapis.com at a mock or corporate gateway and typo-ing the URL (e.g. missing scheme, embedded space); passing a nil context from a hand-rolled caller instead of context.Background().
Related errors
- create Claude OAuth %s request: %w
- Codex live multipart boundary is missing
- antigravity userinfo: create request: %w
- redirect location is not absolute
- Codex live request body too large
AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15).
Data as JSON: /api/errors/85d7d1191b089ae0.
Report an issue: GitHub.