{"record":{"id":"838e7ec4138af239","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-838e7e","errorCode":null,"errorMessage":"请先扫码登录微信","messagePattern":"请先扫码登录微信","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/connect/mod.rs","lineNumber":111,"sourceCode":"            account_id: String::new(),\n            has_token: false,\n            last_peer_id: String::new(),\n            last_message_at_ms: 0,\n            processed_messages: 0,\n        }\n    }\n}\n\npub type SharedWeixinConnectStatus = Arc<Mutex<WeixinConnectStatus>>;\n\npub async fn run_weixin_connect(\n    config: WeixinConnectConfig,\n    stop: Arc<AtomicBool>,\n    status: SharedWeixinConnectStatus,\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":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/f2074595a281bc057525c748175c8eb9805b0673/crates/codex-plus-core/src/connect/mod.rs#L93-L129","documentation":"run_weixin_connect refuses to start when the normalized WeixinConnectConfig has an empty token: the WeChat bridge requires a token obtained by scanning the login QR code, and every later call would fail auth anyway, so it fails fast with a user-action message.","triggerScenarios":"Starting the connect task with config.token empty or whitespace: the user never completed QR login, the token was cleared, or the UI passed the config before login finished.","commonSituations":"Fresh install where login was skipped; token lost after app data reset; calling run_weixin_connect programmatically without going through the fetch_qr_code and poll_qr_status flow.","solutions":["Complete WeChat login in the Codex++ manager: fetch the QR code and scan it so a token is stored","When driving the API directly, obtain the token via fetch_qr_code plus poll_qr_status before building the config","Re-scan when the stored session was invalidated"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if config.token.trim().is_empty() {\n    // drive the QR flow first: fetch_qr_code then poll_qr_status\n    bail!(\"login required before starting the connector\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check has_token in WeixinConnectStatus before spawning the connect task","Store the token right after a successful QR scan","Clear saved state on logout so an empty token cannot reach the runner"],"tags":["weixin","auth","token","login-required"],"backgroundTag":"missing-auth-token","analyzedSha":"f2074595a281bc057525c748175c8eb9805b0673","analyzedAt":"2026-08-23T12:52:24.489Z","contentChangedAt":"2026-08-23T12:52:24.489Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}