{"record":{"id":"6a416018ed07b4a4","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-6a4160","errorCode":null,"errorMessage":"微信二维码响应缺少必要字段","messagePattern":"微信二维码响应缺少必要字段","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/weixin.rs","lineNumber":161,"sourceCode":"        let client = Self::new(base_url, \"\", route_tag)?;\n        let mut url = client.endpoint(\"ilink/bot/get_bot_qrcode\")?;\n        url.query_pairs_mut().append_pair(\"bot_type\", \"3\");\n        let response = client\n            .client\n            .get(url)\n            .headers(client.route_headers(false)?)\n            .timeout(Duration::from_secs(40))\n            .send()\n            .await\n            .context(\"获取微信登录二维码失败\")?;\n        let (status, bytes) =\n            read_response_limited(response, MAX_SMALL_RESPONSE_BYTES, \"微信二维码\").await?;\n        if !status.is_success() {\n            bail!(\"获取微信登录二维码失败：HTTP {status}\");\n        }\n        let qr: WeixinQrCode = serde_json::from_slice(&bytes).context(\"微信二维码响应格式无效\")?;\n        if qr.qr_code.trim().is_empty() || qr.qr_content.trim().is_empty() {\n            bail!(\"微信二维码响应缺少必要字段\");\n        }\n        Ok(qr)\n    }\n\n    pub async fn poll_qr_status(\n        base_url: &str,\n        route_tag: &str,\n        qr_code: &str,\n    ) -> anyhow::Result<WeixinQrStatus> {\n        let client = Self::new(base_url, \"\", route_tag)?;\n        let mut url = client.endpoint(\"ilink/bot/get_qrcode_status\")?;\n        url.query_pairs_mut().append_pair(\"qrcode\", qr_code);\n        let response = client\n            .client\n            .get(url)\n            .headers(client.route_headers(true)?)\n            .timeout(Duration::from_secs(40))\n            .send()","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/weixin.rs#L143-L179","documentation":"After a successful HTTP response, fetch_qr_code deserializes the body into WeixinQrCode and validates that both qr_code and qr_content are non-empty; if either is missing or blank it bails with this message. This guards against servers returning 200 with an unusable/partial payload.","triggerScenarios":"The WeChat QR endpoint returns HTTP 200 but the JSON body lacks `qr_code` or `qr_content`, or contains them as empty/whitespace-only strings.","commonSituations":"WeChat API changed its response schema (fields renamed); service degradation returning empty payloads with 200; a proxy/captive portal injecting HTML that coincidentally parses or a stub server in dev returning {}.","solutions":["Log the raw response body to inspect what fields were actually returned","Check for a WeChat API schema update and update the WeixinQrCode struct/serde attributes","Retry the request — a transiently empty payload usually succeeds on retry","Confirm you are hitting the real API, not a stub/proxy returning empty JSON"],"exampleFix":"// before\nlet qr: WeixinQrCode = serde_json::from_slice(&bytes)?; // missing field => panic-ish bail\n// after\n#[derive(Deserialize)]\nstruct WeixinQrCode {\n    #[serde(default)]\n    qr_code: String,\n    #[serde(default, alias = \"qrImg\")]\n    qr_content: String, // tolerate renamed fields via alias\n}","handlingStrategy":"validation","validationCode":"#[derive(serde::Deserialize)]\nstruct WeixinQrCode { qr_code: String, qr_content: String }\nfn qr_payload_ok(bytes: &[u8]) -> bool {\n    serde_json::from_slice::<WeixinQrCode>(bytes)\n        .map(|q| !q.qr_code.trim().is_empty() && !q.qr_content.trim().is_empty())\n        .unwrap_or(false)\n}","typeGuard":"fn is_valid_qr(q: &WeixinQrCode) -> bool {\n    !q.qr_code.trim().is_empty() && !q.qr_content.trim().is_empty()\n}","tryCatchPattern":"let qr = fetch_qr_code(base_url).await.inspect_err(|e| {\n    if e.to_string().contains(\"缺少必要字段\") { log_raw_response(); }\n})?;","preventionTips":["Log raw response bodies on validation failure","Pin/alert on WeChat API schema changes","Retry once — empty 200 payloads are often transient","Use a real endpoint, not a stub, in production paths"],"tags":["http","wechat","validation","schema"],"backgroundTag":"unexpected-response-shape","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}