router-for-me/CLIProxyAPI · error

antigravity userinfo: decode response: %w

Error message

antigravity userinfo: decode response: %w

What it means

Userinfo returned 2xx but the body could not be decoded into the userInfo struct. The response was not the expected JSON object — possibly empty, HTML, or a changed schema — so fields like email could not be extracted.

Source

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

		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)
		}
		body := strings.TrimSpace(string(bodyBytes))
		if body == "" {
			return "", fmt.Errorf("antigravity userinfo: request failed: status %d", resp.StatusCode)
		}
		return "", fmt.Errorf("antigravity userinfo: request failed: status %d: %s", resp.StatusCode, body)
	}
	var info userInfo
	if errDecode := json.NewDecoder(resp.Body).Decode(&info); errDecode != nil {
		return "", fmt.Errorf("antigravity userinfo: decode response: %w", errDecode)
	}
	email := strings.TrimSpace(info.Email)
	if email == "" {
		return "", fmt.Errorf("antigravity userinfo: response missing email")
	}
	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)

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Log the raw body prefix on decode failure to identify interception or schema drift
  2. Bypass or trust the intercepting proxy and retry
  3. If the schema changed, update the userInfo struct's json tags
Defensive patterns

Strategy: try-catch

Validate before calling

if !json.Valid(rawPrefix) {
	// interception/truncation — retry the userinfo GET
}

Try / catch

var syntaxErr *json.SyntaxError
if errors.As(err, &syntaxErr) {
	// body not JSON — proxy or outage; retry or bypass proxy
}

Prevention

When it happens

Trigger: Empty 200 body; proxy replacing the response with HTML; Google changing the userinfo response shape; body truncated by a timeout mid-decode.

Common situations: Interception on the userinfo host; flaky networks truncating responses.

Related errors


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