{"record":{"id":"f828d7398401168a","repo":"BigPizzaV3/CodexPlusPlus","slug":"codex-f828d7","errorCode":null,"errorMessage":"不是 Codex++ 会话导入链接","messagePattern":"不是 Codex\\+\\+ 会话导入链接","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/session_share.rs","lineNumber":18,"sourceCode":"use aes_gcm::{Aes256Gcm, KeyInit, Nonce, aead::Aead};\nuse anyhow::{Context, bail};\nuse base64::Engine;\nuse rusqlite::Connection;\nuse serde_json::{Value, json};\nuse std::fs::{self, OpenOptions};\nuse std::io::Write;\nuse std::path::{Path, PathBuf};\nuse std::time::{SystemTime, UNIX_EPOCH};\nuse uuid::Uuid;\n\nconst MAX_ROLLOUT_BYTES: usize = 16 * 1024 * 1024;\nconst SHARE_HOSTS: &[&str] = &[\"share.codexpp.cc\", \"codexpp-share.pages.dev\"];\n\npub fn save_pending_session_share_from_protocol_url(url: &str) -> anyhow::Result<String> {\n    let parsed = reqwest::Url::parse(url).context(\"会话导入链接格式无效\")?;\n    if parsed.scheme() != \"codexplusplus\" || parsed.host_str() != Some(\"session\") {\n        bail!(\"不是 Codex++ 会话导入链接\");\n    }\n    let share_url = parsed\n        .query_pairs()\n        .find(|(key, _)| key == \"url\")\n        .map(|(_, value)| value.into_owned())\n        .context(\"会话导入链接缺少分享 URL\")?;\n    validate_share_url(&share_url)?;\n    let path = crate::paths::default_pending_session_share_path();\n    if let Some(parent) = path.parent() {\n        fs::create_dir_all(parent)?;\n    }\n    fs::write(&path, format!(\"{share_url}\\n\"))?;\n    Ok(share_url)\n}\n\npub fn load_pending_session_share() -> anyhow::Result<Option<String>> {\n    let path = crate::paths::default_pending_session_share_path();\n    if !path.exists() {","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/session_share.rs#L1-L36","documentation":"save_pending_session_share_from_protocol_url first parses the codexpp:// protocol URL, then requires its host to be share.codexpp.cc or codexpp-share.pages.dev (SHARE_HOSTS) with a fragment. This bail is the shape guard: the URL is not a recognized Codex++ session-import link, so no pending share is stored.","triggerScenarios":"Calling save_pending_session_share_from_protocol_url with a URL whose scheme is not \"codexplusplus\" or whose host is not \"session\", e.g. a plain https share link passed directly.","commonSituations":"Pasting the underlying https://share.codexpp.cc/... link into the importer instead of the codexplusplus://session?url=... wrapper; OS handlers mangling the custom scheme; using an old scheme format.","solutions":["Pass the full codexplusplus://session?url=... link produced by the share dialog","If you only have the https share URL, call load_pending_session_share or import_shared_session_url directly instead","Check the OS URL-handler registration is intact so the scheme survives round-trips"],"exampleFix":"// before\nsave_pending_session_share_from_protocol_url(\"https://share.codexpp.cc/s/abc#key\")?;\n// after\nsave_pending_session_share_from_protocol_url(\"codexplusplus://session?url=https%3A%2F%2Fshare.codexpp.cc%2Fs%2Fabc%23key\")?;","handlingStrategy":"type-guard","validationCode":"fn is_codexpp_protocol_url(url: &str) -> bool {\n    reqwest::Url::parse(url).map(|u| u.scheme() == \"codexplusplus\" && u.host_str() == Some(\"session\")).unwrap_or(false)\n}","typeGuard":"fn as_session_protocol_url(url: &str) -> Option<String> {\n    let u = reqwest::Url::parse(url).ok()?;\n    (u.scheme() == \"codexplusplus\" && u.host_str() == Some(\"session\")).then(|| url.to_string())\n}","tryCatchPattern":"match save_pending_session_share_from_protocol_url(raw) {\n    Ok(id) => proceed(id),\n    Err(e) if e.to_string().contains(\"会话导入链接\") => prompt_user_to_use_protocol_link(),\n    Err(e) => show_error(e),\n}","preventionTips":["Register and use the codexplusplus:// URL handler end-to-end","Distinguish between https share links and protocol wrapper links in the UI","URL-encode the inner https share URL inside the protocol link"],"tags":["url","import","validation"],"backgroundTag":"invalid-url-format","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"}