BigPizzaV3/CodexPlusPlus · error · anyhow::Error

获取微信登录二维码失败:HTTP {status}

Error message

获取微信登录二维码失败:HTTP {status}

What it means

fetch_qr_code GETs the ilink bot QR endpoint with a 40s timeout and a size-limited body to obtain a WeChat login QR code; a non-2xx HTTP status aborts with this error. Transport-level failures surface separately through context, so this is specifically an HTTP error status from the gateway.

Source

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

        })
    }

    pub async fn fetch_qr_code(base_url: &str, route_tag: &str) -> anyhow::Result<WeixinQrCode> {
        let client = Self::new(base_url, "", route_tag)?;
        let mut url = client.endpoint("ilink/bot/get_bot_qrcode")?;
        url.query_pairs_mut().append_pair("bot_type", "3");
        let response = client
            .client
            .get(url)
            .headers(client.route_headers(false)?)
            .timeout(Duration::from_secs(40))
            .send()
            .await
            .context("获取微信登录二维码失败")?;
        let (status, bytes) =
            read_response_limited(response, MAX_SMALL_RESPONSE_BYTES, "微信二维码").await?;
        if !status.is_success() {
            bail!("获取微信登录二维码失败:HTTP {status}");
        }
        let qr: WeixinQrCode = serde_json::from_slice(&bytes).context("微信二维码响应格式无效")?;
        if qr.qr_code.trim().is_empty() || qr.qr_content.trim().is_empty() {
            bail!("微信二维码响应缺少必要字段");
        }
        Ok(qr)
    }

    pub async fn poll_qr_status(
        base_url: &str,
        route_tag: &str,
        qr_code: &str,
    ) -> anyhow::Result<WeixinQrStatus> {
        let client = Self::new(base_url, "", route_tag)?;
        let mut url = client.endpoint("ilink/bot/get_qrcode_status")?;
        url.query_pairs_mut().append_pair("qrcode", qr_code);
        let response = client
            .client

View on GitHub (pinned to f2074595a2)

Solutions

  1. Verify base_url reaches the ilink gateway by requesting the endpoint directly and checking the status
  2. Confirm route_tag and the bot_type query match the working manager build
  3. Retry after a short wait for transient 5xx and inspect the body via a proxy for 4xx cause
  4. Update codex-plus-manager if the endpoint contract changed
Defensive patterns

Strategy: retry

Validate before calling

// prove the endpoint is reachable and 2xx before showing UI
let probe = reqwest::Client::new().get(format!("{base}/ilink/bot/get_bot_qrcode?bot_type=3")).send().await?;
ensure!(probe.status().is_success(), "gateway unhealthy");

Try / catch

let qr = match WeixinClient::fetch_qr_code(&base, &tag).await {
    Ok(qr) => qr,
    Err(e) if e.to_string().contains("HTTP ") => {
        tokio::time::sleep(Duration::from_secs(2)).await;
        WeixinClient::fetch_qr_code(&base, &tag).await?
    }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: base_url points at the wrong gateway or a mistyped host (404); the route tag or bot identity is rejected (4xx); the WeChat ilink service returns 5xx during maintenance.

Common situations: Typo in base_url; gateway endpoint moved; rate-limited or region-blocked IP; corporate proxy returning 407 or 502.

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@f2074595a2 (2026-08-23). Data as JSON: /api/errors/6ffa4960441a301d. Report an issue: GitHub.