{"record":{"id":"0e918d0b7568e42f","repo":"BigPizzaV3/CodexPlusPlus","slug":"error-0e918d","errorCode":null,"errorMessage":"待处理的一键换肤记录无效","messagePattern":"待处理的一键换肤记录无效","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/dream_skin_community.rs","lineNumber":242,"sourceCode":"\nfn version_id_from_link(url: &str) -> anyhow::Result<String> {\n    let version_id = url\n        .strip_prefix(\"dreamskin://apply?version=\")\n        .or_else(|| url.strip_prefix(\"dreamskin://apply/?version=\"))\n        .context(\"一键换肤链接无效\")?;\n    validate_version_id(version_id)?;\n    Ok(version_id.to_string())\n}\n\npub fn load_pending_community_link() -> anyhow::Result<Option<String>> {\n    let path = pending_link_path();\n    if !path.exists() {\n        return Ok(None);\n    }\n    let metadata = std::fs::symlink_metadata(&path)?;\n    if !metadata.file_type().is_file() || metadata.file_type().is_symlink() || metadata.len() > 4096\n    {\n        bail!(\"待处理的一键换肤记录无效\");\n    }\n    let value: serde_json::Value = serde_json::from_slice(&std::fs::read(path)?)?;\n    let version_id = value\n        .get(\"versionId\")\n        .and_then(serde_json::Value::as_str)\n        .context(\"待处理的一键换肤记录缺少版本 ID\")?\n        .to_string();\n    validate_version_id(&version_id)?;\n    Ok(Some(version_id))\n}\n\npub fn clear_pending_community_link() -> anyhow::Result<()> {\n    let path = pending_link_path();\n    match std::fs::remove_file(path) {\n        Ok(()) => Ok(()),\n        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),\n        Err(error) => Err(error.into()),\n    }","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/dream_skin_community.rs#L224-L260","documentation":"load_pending_community_link reads the pending one-click skin-link record file and bails if the file is not a small (<= 4096 bytes) regular file. Symlinks, directories, or oversized files indicate a corrupted or malicious pending record, so it is rejected instead of parsed. Note: the record also must contain a valid versionId or a separate error fires.","triggerScenarios":"Calling load_pending_community_link when the pending-record file at state_dir is: a symlink, a directory, a special file, or larger than 4096 bytes.","commonSituations":"Another process wrote garbage or logs into the pending file; a user replaced the file with a symlink during state-dir sharing; disk corruption or interrupted write left an oversized partial file.","solutions":["Delete the invalid pending-record file so the next load returns Ok(None) and a fresh record can be written.","Re-run the one-click link flow to recreate the pending record.","Check for processes concurrently writing to the state dir and serialize state-dir access.","Inspect the file's symlink_metadata to confirm it is a small regular file before debugging further."],"exampleFix":"// before\nlet pending = load_pending_community_link(state_dir)?;\n// after\nlet pending = match load_pending_community_link(state_dir) {\n    Ok(p) => p,\n    Err(_) => { let _ = std::fs::remove_file(pending_path(state_dir)); None }\n};","handlingStrategy":"try-catch","validationCode":"// Rust\nlet md = std::fs::symlink_metadata(&path)?;\nlet ok = md.is_file() && md.len() <= 4096;","typeGuard":null,"tryCatchPattern":"// Rust\nlet pending = load_pending_community_link(state_dir).unwrap_or(None); // treat invalid record as absent and recreate it","preventionTips":["Treat the pending record as disposable: delete and recreate on any read error","Write the record atomically (temp file + rename)","Don't share/symlink the state dir across machines or users"],"tags":["validation","file","state-management"],"backgroundTag":"file-read-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"}