BigPizzaV3/CodexPlusPlus · error

查询微信扫码状态失败:HTTP

Error message

查询微信扫码状态失败:HTTP {status}

What it means

poll_qr_status queries whether the user scanned/confirmed the WeChat QR login; after reading the size-capped response it checks HTTP success and bails with this message on a non-2xx status. Transport failures are wrapped with a separate context ('查询微信扫码状态失败'), while this variant carries the actual HTTP status.

Solutions

  1. Honor the status code: 429 → increase polling interval; 401/403 → restart QR login to get a fresh session
  2. Add backoff between poll_qr_status calls rather than tight-looping
  3. Retry on 5xx with exponential backoff
  4. Verify base_url and that the login flow that produced the session token completed

Example fix

// before
loop {
    let st = client.poll_qr_status(base_url, &token).await?; // hard-fails on 429
}
// after
loop {
    match client.poll_qr_status(base_url, &token).await {
        Ok(st) => { if st.confirmed { break st; } }
        Err(e) if is_rate_limited(&e) => tokio::time::sleep(Duration::from_secs(5)).await,
        Err(e) => return Err(e),
    }
    tokio::time::sleep(Duration::from_millis(1000)).await;
}
Defensive patterns

Strategy: retry

Validate before calling

// keep a sane polling interval before calling poll_qr_status
anyhow::ensure!(since_last_poll >= Duration::from_millis(1000), "轮询过快");

Try / catch

match poll_qr_status(base_url, &token).await {
    Err(e) if e.to_string().contains("HTTP 429") => { sleep(5s).await; continue; }
    Err(e) if e.to_string().contains("HTTP 40") => return Err(anyhow!("会话失效,请重新扫码")),
    other => other?,
}

Prevention

When it happens

Trigger: Calling poll_qr_status while the WeChat status endpoint returns 4xx/5xx — e.g. expired/invalid login session token, rate limiting from polling too fast, or server-side errors.

Common situations: Polling interval too aggressive causing 429; login session expired mid-poll (401/403); WeChat API outage (5xx); wrong base_url.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/9d2483de39028d87. Report an issue: GitHub.

Appendix: source

Thrown at crates/codex-plus-core/src/connect/weixin.rs:194

            .get(url)
            .headers(client.route_headers(true)?)
            .timeout(Duration::from_secs(40))
            .send()
            .await;
        let response = match response {
            Ok(response) => response,
            Err(error) if error.is_timeout() => {
                return Ok(WeixinQrStatus {
                    status: "wait".to_string(),
                    ..WeixinQrStatus::default()
                });
            }
            Err(error) => return Err(error).context("查询微信扫码状态失败"),
        };
        let (status, bytes) =
            read_response_limited(response, MAX_SMALL_RESPONSE_BYTES, "微信扫码状态").await?;
        if !status.is_success() {
            bail!("查询微信扫码状态失败:HTTP {status}");
        }
        serde_json::from_slice(&bytes).context("微信扫码状态响应格式无效")
    }

    pub async fn get_updates(
        &self,
        get_updates_buf: &str,
        timeout_ms: u64,
    ) -> anyhow::Result<WeixinUpdates> {
        let request_body = json!({
            "get_updates_buf": get_updates_buf,
            "base_info": { "channel_version": CHANNEL_VERSION }
        });
        let timeout_ms = timeout_ms.clamp(1_000, 60_000);
        let response = self
            .client
            .post(self.endpoint("ilink/bot/getupdates")?)
            .headers(self.auth_headers()?)

View on GitHub (pinned to b1ed92e5e4)