BigPizzaV3/CodexPlusPlus · error · anyhow::Error

分享链接缺少解密密钥

Error message

分享链接缺少解密密钥

What it means

Thrown by validate_share_url when the URL parses, is https on an allowed host, but has no fragment at all — the AES key is transported in the #k= fragment, so a fragment-less link cannot decrypt anything. The offending input is the share URL missing its fragment; the guard is a cheap pre-check before the more specific "缺少解密密钥" lookup.

Source

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

                .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)
            .with_context(|| format!("分享数据 {field} 无效"))
    };
    let key = base64::engine::general_purpose::URL_SAFE_NO_PAD

View on GitHub (pinned to f2074595a2)

Solutions

  1. 使用完整未截断的分享链接(含 #k=... 部分)
  2. 重新生成分享链接
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/codex-plus-core/src/session_share.rs:113 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/12c2a0a8e6b79edb. Report an issue: GitHub.