{"record":{"id":"92debf5d534020c3","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-92debf","errorCode":null,"errorMessage":"分享会话解密失败","messagePattern":"分享会话解密失败","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":142,"sourceCode":"            .get(field)\n            .and_then(Value::as_str)\n            .with_context(|| format!(\"分享数据缺少 {field}\"))?;\n        base64::engine::general_purpose::URL_SAFE_NO_PAD\n            .decode(value)\n            .with_context(|| format!(\"分享数据 {field} 无效\"))\n    };\n    let key = base64::engine::general_purpose::URL_SAFE_NO_PAD\n        .decode(key_value)\n        .context(\"分享链接解密密钥无效\")?;\n    let iv = decode(\"iv\")?;\n    let ciphertext = decode(\"ciphertext\")?;\n    if key.len() != 32 || iv.len() != 12 || ciphertext.len() > MAX_ROLLOUT_BYTES + 16 {\n        bail!(\"分享数据大小或格式无效\");\n    }\n    let cipher = Aes256Gcm::new_from_slice(&key).context(\"创建会话解密器失败\")?;\n    cipher\n        .decrypt(Nonce::from_slice(&iv), ciphertext.as_ref())\n        .map_err(|_| anyhow::anyhow!(\"分享会话解密失败\"))\n}\n\npub fn import_rollout_file(home: &Path, source_path: &Path) -> anyhow::Result<Value> {\n    let bytes = fs::read(source_path)\n        .with_context(|| format!(\"读取会话文件失败：{}\", source_path.display()))?;\n    if bytes.len() > MAX_ROLLOUT_BYTES {\n        bail!(\"会话文件超过导入大小限制\");\n    }\n    let content = String::from_utf8(bytes).context(\"会话文件不是有效的 UTF-8\")?;\n    if let Ok(payload) = serde_json::from_str::<Value>(&content)\n        && payload.get(\"kind\").and_then(Value::as_str) == Some(\"codex-rollout\")\n    {\n        return import_rollout(home, &payload);\n    }\n    let session_id = find_session_id(&content)\n        .or_else(|| {\n            source_path\n                .file_stem()","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L124-L160","documentation":"decrypt_shared_payload decrypts an AES-256-GCM encrypted session share payload embedded in a share URL. If the ciphertext fails authentication/decryption (wrong key fragment, tampered data, or truncated payload), it returns this error. AES-GCM is authenticated, so any bit change in key, IV, or ciphertext causes failure.","triggerScenarios":"Importing a share URL whose key fragment was modified or re-generated; the shared URL was truncated by a chat/messaging client; payload copied partially; wrong share version.","commonSituations":"Messaging apps mangling long URLs (line breaks, HTML escaping); user manually editing the share link; decrypting a share with an app build using different key derivation.","solutions":["Re-copy the full, unmodified share URL from the sender and retry the import.","Verify the URL was not line-wrapped or HTML-escaped by the messaging channel; re-share via a file if needed.","Ensure both sides use compatible app versions (same key derivation).","Ask the sender to regenerate the share link and re-import."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check: share URL must contain key, iv and ciphertext fragments of expected shape\nfunction shareFragmentsLookValid(url: URL): boolean {\n  const key = url.searchParams.get('key');\n  const iv = url.searchParams.get('iv');\n  return !!key && key.length >= 43 && !!iv && iv.length >= 16; // base64 sizes\n}","typeGuard":null,"tryCatchPattern":"match import_shared_session_url(&url) {\n    Ok(v) => v,\n    Err(e) if e.to_string().contains(\"分享会话解密失败\") => {\n        // prompt user to re-obtain an intact share link\n        bail!(\"分享链接无效或已被篡改，请向分享者重新获取\")\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Share links via channels that preserve long URLs intact (file export preferred).","Never manually edit share URL fragments.","Keep both parties on the same app version for key compatibility.","Validate base64 fragment lengths before import."],"tags":["crypto","aes-gcm","decryption"],"backgroundTag":"decryption-failed","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}