BigPizzaV3/CodexPlusPlus · error · anyhow::Error

请先扫码登录微信

Error message

请先扫码登录微信

What it means

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.

Source

Thrown at crates/codex-plus-core/src/connect/mod.rs:111

            account_id: String::new(),
            has_token: false,
            last_peer_id: String::new(),
            last_message_at_ms: 0,
            processed_messages: 0,
        }
    }
}

pub type SharedWeixinConnectStatus = Arc<Mutex<WeixinConnectStatus>>;

pub async fn run_weixin_connect(
    config: WeixinConnectConfig,
    stop: Arc<AtomicBool>,
    status: SharedWeixinConnectStatus,
) -> anyhow::Result<()> {
    let config = config.normalized();
    if config.token.is_empty() {
        bail!("请先扫码登录微信");
    }
    let work_dir = if config.work_dir.is_empty() {
        std::env::current_dir().context("无法读取当前工作目录")?
    } else {
        PathBuf::from(&config.work_dir)
    };
    if !work_dir.is_dir() {
        bail!("工作目录不存在:{}", work_dir.display());
    }

    update_status(&status, |current| {
        current.state = "starting".to_string();
        current.message = "正在连接微信和 Codex app-server...".to_string();
        current.account_id = config.account_id.clone();
        current.has_token = true;
    });

    let client = WeixinClient::new(&config.base_url, &config.token, &config.route_tag)?;

View on GitHub (pinned to f2074595a2)

Solutions

  1. Complete WeChat login in the Codex++ manager: fetch the QR code and scan it so a token is stored
  2. When driving the API directly, obtain the token via fetch_qr_code plus poll_qr_status before building the config
  3. Re-scan when the stored session was invalidated
Defensive patterns

Strategy: validation

Validate before calling

if config.token.trim().is_empty() {
    // drive the QR flow first: fetch_qr_code then poll_qr_status
    bail!("login required before starting the connector");
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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