{"record":{"id":"838e7ec4138af239","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-838e7e","errorCode":null,"errorMessage":"请先扫码登录微信","messagePattern":"请先扫码登录微信","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/mod.rs","lineNumber":144,"sourceCode":"\npub async fn run_weixin_connect(\n    config: WeixinConnectConfig,\n    stop: Arc<AtomicBool>,\n    status: SharedWeixinConnectStatus,\n) -> anyhow::Result<()> {\n    let codex_path = WeixinCodexPath::new(&config.codex_path);\n    run_weixin_connect_with_codex_path(config, stop, status, codex_path).await\n}\n\npub async fn run_weixin_connect_with_codex_path(\n    config: WeixinConnectConfig,\n    stop: Arc<AtomicBool>,\n    status: SharedWeixinConnectStatus,\n    codex_path: WeixinCodexPath,\n) -> anyhow::Result<()> {\n    let config = config.normalized();\n    if config.token.is_empty() {\n        bail!(\"请先扫码登录微信\");\n    }\n    let work_dir = if config.work_dir.is_empty() {\n        std::env::current_dir().context(\"无法读取当前工作目录\")?\n    } else {\n        PathBuf::from(&config.work_dir)\n    };\n    if !work_dir.is_dir() {\n        bail!(\"工作目录不存在：{}\", work_dir.display());\n    }\n\n    update_status(&status, |current| {\n        current.state = \"starting\".to_string();\n        current.message = \"正在连接微信和 Codex app-server...\".to_string();\n        current.account_id = config.account_id.clone();\n        current.has_token = true;\n    });\n\n    let client = WeixinClient::new(&config.base_url, &config.token, &config.route_tag)?;","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/connect/mod.rs#L126-L162","documentation":"run_weixin_connect_with_codex_path refuses to start the WeChat bridge when the stored WeChat login token is empty. The token is produced by the QR-code login flow; without it the bridge cannot authenticate requests to the WeChat API. This is a deliberate pre-flight guard so the connect flow fails fast with a user-actionable message instead of failing later on an unauthenticated HTTP call.","triggerScenarios":"Calling run_weixin_connect (or run_weixin_connect_with_codex_path) with a WeixinConfig whose `token` field is an empty string after normalization.","commonSituations":"Fresh install where the user never completed QR-code login; config file reset or migrated without the token field; a previous logout cleared the token but an automation still invokes connect.","solutions":["Complete the WeChat QR-code login flow first (fetch_qr_code + poll_qr_status) to obtain and persist the token","Inspect the stored WeixinConfig and confirm `token` is populated before calling connect","Re-scan the QR code if the saved token expired or was cleared"],"exampleFix":"// before\nrun_weixin_connect(config).await?;\n// after\nif config.normalized().token.is_empty() {\n    let login = weixin_login_flow().await?; // performs QR login, stores token\n    config.token = login.token;\n}\nrun_weixin_connect(config).await?;","handlingStrategy":"validation","validationCode":"if config.normalized().token.is_empty() {\n    return Err(anyhow!(\"请先完成微信扫码登录后再连接\"));\n}","typeGuard":"fn has_weixin_token(c: &WeixinConfig) -> bool { !c.normalized().token.trim().is_empty() }","tryCatchPattern":"match run_weixin_connect(config).await {\n    Err(e) if e.to_string().contains(\"请先扫码登录微信\") => prompt_qr_login(),\n    other => other,\n}","preventionTips":["Always run the QR login flow before connect","Persist the token after login and reload it on startup","Surface login state in the UI so connect isn't attempted while logged out"],"tags":["authentication","wechat","config","rust"],"backgroundTag":"authentication-required","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"}