BigPizzaV3/CodexPlusPlus · error · anyhow::Error

仅支持 Codex++ 分享站点链接

Error message

仅支持 Codex++ 分享站点链接

What it means

Thrown by validate_share_url when the URL's scheme is not https or its host is not one of SHARE_HOSTS (share.codexpp.cc / codexpp-share.pages.dev). This is an origin allow-list on the session-share fetcher; the offending input is the user-supplied share URL, rejected before any network request is made. Called from save/load/import paths alike.

Source

Thrown at crates/codex-plus-core/src/session_share.rs:110

        .fragment()
        .and_then(|fragment| {
            fragment
                .split('&')
                .find_map(|pair| pair.strip_prefix("k="))
        })
        .context("分享链接缺少解密密钥")?;
    let plaintext = decrypt_shared_payload(encrypted, key_value)?;
    let payload: Value = serde_json::from_slice(&plaintext).context("分享会话内容格式无效")?;
    if payload.get("kind").and_then(Value::as_str) != Some("codex-rollout") {
        bail!("当前分享内容不是可导入的 Codex rollout 会话");
    }
    import_rollout(home, &payload)
}

fn validate_share_url(url: &str) -> anyhow::Result<reqwest::Url> {
    let parsed = reqwest::Url::parse(url.trim()).context("分享 URL 格式无效")?;
    if parsed.scheme() != "https" || !parsed.host_str().is_some_and(|host| SHARE_HOSTS.contains(&host)) {
        bail!("仅支持 Codex++ 分享站点链接");
    }
    if parsed.fragment().is_none() {
        bail!("分享链接缺少解密密钥");
    }
    Ok(parsed)
}

fn decrypt_shared_payload(encrypted: &Value, key_value: &str) -> anyhow::Result<Vec<u8>> {
    if encrypted.get("v").and_then(Value::as_u64) != Some(1) {
        bail!("不支持此分享的数据格式");
    }
    let decode = |field: &str| -> anyhow::Result<Vec<u8>> {
        let value = encrypted
            .get(field)
            .and_then(Value::as_str)
            .with_context(|| format!("分享数据缺少 {field}"))?;
        base64::engine::general_purpose::URL_SAFE_NO_PAD
            .decode(value)

View on GitHub (pinned to f2074595a2)

Solutions

  1. 使用官方分享站点域名下的链接
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/session_share.rs:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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