BigPizzaV3/CodexPlusPlus · error · anyhow::Error

不支持此分享的数据格式

Error message

不支持此分享的数据格式

What it means

decrypt_shared_payload checks the encrypted envelope's version field 'v' against supported values and bails otherwise. The share record decrypted (or at least parsed) but was sealed with an envelope format this build does not understand — typically a newer client sharing to an older app.

Solutions

  1. Upgrade Codex++ to a version that supports the share format's v field
  2. Re-share the session from a version using envelope v=1
  3. If you control the payload, add/fix "v": 1 in the encrypted JSON

Example fix

// before
{"ciphertext": "...", "iv": "..."} // missing v
// after
{"v": 1, "ciphertext": "...", "iv": "..."}
Defensive patterns

Strategy: try-catch

Validate before calling

fn envelope_is_v1(encrypted: &serde_json::Value) -> bool {
    encrypted.get("v").and_then(serde_json::Value::as_u64) == Some(1)
}

Try / catch

match import_shared_session_url(home, url) {
    Ok(session) => load(session),
    Err(e) if e.to_string().contains("数据格式") => suggest_upgrade_or_reshare(),
    Err(e) => show_error(e),
}

Prevention

When it happens

Trigger: The encrypted JSON passed to import_shared_session_url has encrypted["v"] not equal to 1 (missing, string, or a future version number).

Common situations: Importing shares produced by a newer Codex++ that bumped the envelope version; manually constructed payloads omitting "v"; shares from a fork using a different format.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

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

        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
        .decode(key_value)
        .context("分享链接解密密钥无效")?;
    let iv = decode("iv")?;
    let ciphertext = decode("ciphertext")?;
    if key.len() != 32 || iv.len() != 12 || ciphertext.len() > MAX_ROLLOUT_BYTES + 16 {
        bail!("分享数据大小或格式无效");
    }

View on GitHub (pinned to b1ed92e5e4)