BigPizzaV3/CodexPlusPlus · error · anyhow::Error

微信二维码响应缺少必要字段

Error message

微信二维码响应缺少必要字段

What it means

The QR endpoint returned 2xx and the body parsed as JSON, but qr_code or qr_content came back empty or whitespace, so there is nothing to render or poll. The library refuses rather than showing a blank code; parse failures raise a separate format error.

Source

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

        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
            .get(url)
            .headers(client.route_headers(true)?)
            .timeout(Duration::from_secs(40))
            .send()

View on GitHub (pinned to f2074595a2)

Solutions

  1. Retry fetching a fresh QR code, transient provisioning lag often clears
  2. Confirm route_tag and bot_type match a provisioned bot
  3. Update codex-plus-manager if the field contract changed
Defensive patterns

Strategy: try-catch

Try / catch

let qr = match WeixinClient::fetch_qr_code(&base, &tag).await {
    Ok(qr) => qr,
    Err(e) if e.to_string().contains("缺少必要字段") => {
        // empty payload: fetch a fresh code rather than rendering blank
        WeixinClient::fetch_qr_code(&base, &tag).await?
    }
    Err(e) => return Err(e),
};

Prevention

When it happens

Trigger: The gateway returns a well-formed 200 with empty fields: service degraded, the bot is not provisioned for the route tag, or an API contract change renamed the fields.

Common situations: ilink maintenance windows; a new bot not yet activated; version mismatch between manager and gateway.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@f2074595a2 (2026-08-23). Data as JSON: /api/errors/6a416018ed07b4a4. Report an issue: GitHub.