{"record":{"id":"12c2a0a8e6b79edb","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-12c2a0","errorCode":null,"errorMessage":"分享链接缺少解密密钥","messagePattern":"分享链接缺少解密密钥","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":113,"sourceCode":"                .split('&')\n                .find_map(|pair| pair.strip_prefix(\"k=\"))\n        })\n        .context(\"分享链接缺少解密密钥\")?;\n    let plaintext = decrypt_shared_payload(encrypted, key_value)?;\n    let payload: Value = serde_json::from_slice(&plaintext).context(\"分享会话内容格式无效\")?;\n    if payload.get(\"kind\").and_then(Value::as_str) != Some(\"codex-rollout\") {\n        bail!(\"当前分享内容不是可导入的 Codex rollout 会话\");\n    }\n    import_rollout(home, &payload)\n}\n\nfn validate_share_url(url: &str) -> anyhow::Result<reqwest::Url> {\n    let parsed = reqwest::Url::parse(url.trim()).context(\"分享 URL 格式无效\")?;\n    if parsed.scheme() != \"https\" || !parsed.host_str().is_some_and(|host| SHARE_HOSTS.contains(&host)) {\n        bail!(\"仅支持 Codex++ 分享站点链接\");\n    }\n    if parsed.fragment().is_none() {\n        bail!(\"分享链接缺少解密密钥\");\n    }\n    Ok(parsed)\n}\n\nfn decrypt_shared_payload(encrypted: &Value, key_value: &str) -> anyhow::Result<Vec<u8>> {\n    if encrypted.get(\"v\").and_then(Value::as_u64) != Some(1) {\n        bail!(\"不支持此分享的数据格式\");\n    }\n    let decode = |field: &str| -> anyhow::Result<Vec<u8>> {\n        let value = encrypted\n            .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","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L95-L131","documentation":"validate_share_url requires the URL to carry a fragment; the AES key for the encrypted payload is passed only in the fragment (k=...). A share link without a fragment cannot be decrypted, so it is rejected before any network request.","triggerScenarios":"Calling one of the share-import functions with a share URL missing its #k=... fragment — often the fragment is stripped when copying/pasting the link.","commonSituations":"Sharing only the base URL without the key fragment; chat apps or URL sanitizers stripping fragments; the user manually trimming the \"#...\" part of the link.","solutions":["Copy the complete share link including the #k= fragment from the share dialog","Re-share the session to generate a fresh link with its key","Avoid link-shorteners or sanitizers that drop URL fragments"],"exampleFix":"// before\nlet url = \"https://share.codexpp.cc/s/abc\"; // missing fragment\n// after\nlet url = \"https://share.codexpp.cc/s/abc#k=AbCdEf...\"; // full link with key","handlingStrategy":"validation","validationCode":"fn share_url_has_key(url: &str) -> bool {\n    reqwest::Url::parse(url.trim()).map(|u| u.fragment().is_some()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always copy the full share link including the #k= fragment","Avoid link sanitizers/shorteners that strip fragments","UI: detect a missing fragment and warn before submission"],"tags":["url","encryption","missing-key"],"backgroundTag":"missing-required-argument","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"}