router-for-me/CLIProxyAPI · error

execute request: %w

Error message

execute request: %w

What it means

Returned by AntigravityAuth.FetchProjectID when the HTTP POST to https://cloudcode-pa.googleapis.com/v1internal:loadCodeAssist fails at the transport level. This wraps the error from httpClient.Do, so the underlying cause is one of Go's *url.Error values: DNS resolution failure, connection refused, TLS handshake error, proxy misconfiguration, or context cancellation. The client is built with util.SetProxy, so an invalid proxy setting in the SDK config also surfaces here.

Source

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

	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 {
		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 {

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Unwrap with errors.As to *url.Error and read the inner cause: DNS, dial, TLS, or context.Canceled
  2. Verify connectivity: curl -v https://cloudcode-pa.googleapis.com from the same host and proxy environment
  3. Fix or remove the proxy-server setting in config so util.SetProxy builds a working client
  4. If context.Canceled, check whether the parent context passed to FetchProjectID is being cancelled prematurely
Defensive patterns

Strategy: retry

Try / catch

projectID, err := auth.FetchProjectID(ctx, token)
if err != nil {
    var urlErr *url.Error
    if errors.As(err, &urlErr) {
        switch {
        case errors.Is(urlErr.Err, context.Canceled):
            return err // caller cancelled; do not retry
        default:
            return retryWithBackoff(func() (string, error) { return auth.FetchProjectID(ctx, token) })
        }
    }
    return err
}

Prevention

When it happens

Trigger: POST loadCodeAssist while offline, while cloudcode-pa.googleapis.com is DNS-blocked, through a proxy that rejects CONNECT, with an expired corporate TLS root, or when ctx is cancelled before/while the request runs.

Common situations: Corporate egress proxies and Zscaler-style TLS interception without the root CA in the trust store; typo'd proxy-server entry in config.yaml; sandboxed CI without network access; Google endpoint temporarily unreachable.

Related errors


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