BigPizzaV3/CodexPlusPlus · error · anyhow::Error

微信连接 token 为空

Error message

微信连接 token 为空

What it means

The WeChat connect runtime requires a connection token. After normalizing the WeixinConnectConfig built from settings (token/model/sandbox/codex_path), the token field is checked and the command bails if it is empty, because the relay cannot authenticate without it.

Solutions

  1. Open manager settings and fill in the WeChat connect token, then retry the connect command
  2. Validate settings.weixin_connect_token before invoking the connect command
  3. If the settings file lost the token, re-enter it and save so it persists

Example fix

// before
start_weixin_connect();
// after
if (!settings.weixinConnectToken) throw new Error("fill in weixin token first");
start_weixin_connect();
Defensive patterns

Strategy: validation

Validate before calling

if (!settings.weixinConnectToken || settings.weixinConnectToken.trim() === '') throw new Error('weixin token required');

Try / catch

try { await invoke('weixin_connect_start') } catch (e) { if (String(e).includes('token 为空')) openTokenSettings(); else throw e; }

Prevention

When it happens

Trigger: Calling the WeChat connect start command (commands.rs ~1481) when settings.weixin_connect_token resolves to an empty string after normalized().

Common situations: User saved WeChat connect settings without pasting a token; token field was cleared in the UI; settings file migrated/created with default (empty) weixin_connect_token.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/de8bccfedc496069. Report an issue: GitHub.

Appendix: source

Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:1481

}

fn spawn_weixin_connect(
    settings: BackendSettings,
) -> anyhow::Result<codex_plus_core::connect::WeixinConnectStatus> {
    let config = codex_plus_core::connect::WeixinConnectConfig {
        base_url: settings.weixin_connect_base_url,
        token: settings.weixin_connect_token,
        account_id: settings.weixin_connect_account_id,
        allow_from: settings.weixin_connect_allow_from,
        route_tag: settings.weixin_connect_route_tag,
        work_dir: settings.weixin_connect_work_dir,
        model: settings.weixin_connect_model,
        sandbox: settings.weixin_connect_sandbox,
        codex_path: settings.weixin_connect_codex_path,
    }
    .normalized();
    if config.token.is_empty() {
        anyhow::bail!("微信连接 token 为空");
    }
    let stop = Arc::new(AtomicBool::new(false));
    let mut runtime = weixin_runtime()
        .lock()
        .map_err(|_| anyhow::anyhow!("微信连接运行锁已损坏"))?;
    if runtime.is_some() {
        anyhow::bail!("微信连接已在运行或正在停止");
    }
    let codex_path = codex_plus_core::connect::WeixinCodexPath::new(&config.codex_path);
    *runtime = Some(WeixinRuntime {
        stop: Arc::clone(&stop),
        codex_path: codex_path.clone(),
    });
    drop(runtime);
    let status = weixin_status();
    if let Ok(mut current) = status.lock() {
        current.state = "starting".to_string();
        current.message = "正在启动微信连接...".to_string();

View on GitHub (pinned to b1ed92e5e4)