router-for-me/CLIProxyAPI · error

antigravity userinfo: create request: %w

Error message

antigravity userinfo: create request: %w

What it means

Building the GET request to the Google userinfo endpoint failed in http.NewRequestWithContext. Since the method and body are fixed, this occurs when UserInfoEndpoint is not a valid absolute URL, or the context is already cancelled/expired (validated at request-creation time).

Source

Thrown at internal/auth/antigravity/auth.go:189

		return nil, fmt.Errorf("antigravity token exchange: request failed: status %d: %s", resp.StatusCode, body)
	}

	var token TokenResponse
	if errDecode := json.NewDecoder(resp.Body).Decode(&token); errDecode != nil {
		return nil, fmt.Errorf("antigravity token exchange: decode response: %w", errDecode)
	}
	return &token, nil
}

// FetchUserInfo retrieves user email from Google
func (o *AntigravityAuth) FetchUserInfo(ctx context.Context, accessToken string) (string, error) {
	accessToken = strings.TrimSpace(accessToken)
	if accessToken == "" {
		return "", fmt.Errorf("antigravity userinfo: missing access token")
	}
	req, err := http.NewRequestWithContext(ctx, http.MethodGet, UserInfoEndpoint, nil)
	if err != nil {
		return "", fmt.Errorf("antigravity userinfo: create request: %w", err)
	}
	req.Header.Set("Authorization", "Bearer "+accessToken)
	req.Header.Set("User-Agent", o.shortUserAgent())

	resp, errDo := o.httpClient.Do(req)
	if errDo != nil {
		return "", fmt.Errorf("antigravity userinfo: execute request: %w", errDo)
	}
	defer func() {
		if errClose := resp.Body.Close(); errClose != nil {
			log.Errorf("antigravity userinfo: close body error: %v", errClose)
		}
	}()

	if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
		bodyBytes, errRead := io.ReadAll(io.LimitReader(resp.Body, 8<<10))
		if errRead != nil {
			return "", fmt.Errorf("antigravity userinfo: read response: %w", errRead)

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Pass a fresh context with its own timeout instead of reusing a callback request context
  2. Verify UserInfoEndpoint is a well-formed absolute https URL
  3. Create the request promptly after acquiring the token
Defensive patterns

Strategy: validation

Validate before calling

if ctx.Err() != nil {
	return ctx.Err()
}
email, err := auth.FetchUserInfo(ctx, token.AccessToken)

Prevention

When it happens

Trigger: UserInfoEndpoint constant malformed; ctx derived from a finished request or an expired WithTimeout when FetchUserInfo is called late in a flow.

Common situations: Long-running auth flows reusing a callback request context after it ended; forked builds overriding endpoint constants incorrectly.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/17148c0a390f3fbd. Report an issue: GitHub.