BigPizzaV3/CodexPlusPlus · error · anyhow::Error
分享数据大小或格式无效
Error message
分享数据大小或格式无效
What it means
decrypt_shared_payload enforces size constraints: a 32-byte AES-256 key, a 12-byte GCM IV, and ciphertext no larger than MAX_ROLLOUT_BYTES + 16 (16 MiB + GCM tag). Any violation aborts before decryption.
Solutions
- Copy the share link intact so the full base64 key (32 bytes decoded) is present
- Re-share the session if it exceeds the 16 MiB rollout cap (trim or split the session)
- Use URL_SAFE_NO_PAD base64 consistently when constructing share envelopes
- Check that iv is a 12-byte value encoded as base64
Example fix
// before let key = general_purpose::STANDARD.decode(key_value)?; // padded std b64 mismatches // after let key = general_purpose::URL_SAFE_NO_PAD.decode(key_value)?; // matches expected encoding
Defensive patterns
Strategy: validation
Validate before calling
fn share_envelope_sizes_ok(key_value: &str, encrypted: &serde_json::Value, max_cipher: usize) -> bool {
use base64::Engine;
let key_ok = base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(key_value).map(|k| k.len() == 32).unwrap_or(false);
let iv_ok = encrypted.get("iv").and_then(|v| v.as_str()).map(|s| base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(s).map(|i| i.len() == 12).unwrap_or(false)).unwrap_or(false);
let ct_ok = encrypted.get("ciphertext").and_then(|v| v.as_str()).map(|s| base64::engine::general_purpose::URL_SAFE_NO_PAD.decode(s).map(|c| c.len() <= max_cipher).unwrap_or(false)).unwrap_or(false);
key_ok && iv_ok && ct_ok
} Prevention
- Preserve the complete URL fragment so the 32-byte key decodes fully
- Use URL_SAFE_NO_PAD base64 for all envelope fields
- Keep shared rollouts under the 16 MiB cap; trim large sessions before sharing
When it happens
Trigger: The decoded key is not 32 bytes, the decoded iv is not 12 bytes, or the ciphertext exceeds 16 MiB + 16 — e.g. a truncated base64 fragment key, a wrong IV encoding, or an oversized shared session.
Common situations: URL fragment truncated so the base64 key is incomplete; wrong base64 variant (padded vs URL-safe-no-pad); sharing a rollout larger than the 16 MiB cap; hand-assembled envelopes.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- 链接缺少解密密钥。请使用完整的分享链接。
- 收到未加密数据包
- 主题包必须是 32 MiB 以内的普通 ZIP 文件
- 请填写 API 的模型名称
- 官方混合 API 不应在 auth.json 中保存 OPENAI_API_KEY。请清理此供应商的…
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/4659b72a8578efc4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/codex-plus-core/src/session_share.rs:137
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!("分享数据大小或格式无效");
}
let cipher = Aes256Gcm::new_from_slice(&key).context("创建会话解密器失败")?;
cipher
.decrypt(Nonce::from_slice(&iv), ciphertext.as_ref())
.map_err(|_| anyhow::anyhow!("分享会话解密失败"))
}
pub fn import_rollout_file(home: &Path, source_path: &Path) -> anyhow::Result<Value> {
let bytes = fs::read(source_path)
.with_context(|| format!("读取会话文件失败:{}", source_path.display()))?;
if bytes.len() > MAX_ROLLOUT_BYTES {
bail!("会话文件超过导入大小限制");
}
let content = String::from_utf8(bytes).context("会话文件不是有效的 UTF-8")?;
if let Ok(payload) = serde_json::from_str::<Value>(&content)
&& payload.get("kind").and_then(Value::as_str) == Some("codex-rollout")
{
return import_rollout(home, &payload);View on GitHub (pinned to b1ed92e5e4)