{"record":{"id":"b50271188f863c43","repo":"libnyanpasu/clash-nyanpasu","slug":"staged-symlink-specification-is-not-a-regular-file","errorCode":null,"errorMessage":"staged symlink specification is not a regular file","messagePattern":"staged symlink specification is not a regular file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/service/profile_file.rs","lineNumber":790,"sourceCode":"                });\n            }\n        };\n        if file_metadata.is_some() && link_metadata.is_some() {\n            bail!(\"materialization has multiple staged resources\");\n        }\n        if let Some(metadata) = file_metadata {\n            if is_symlink_or_reparse(&metadata) || !metadata.is_file() {\n                bail!(\"staged file is not a regular file\");\n            }\n            let content = std::fs::read(&file_path)?;\n            if hash_tagged(b\"file\", &content) != expected_hash {\n                bail!(\"staged file hash mismatch\");\n            }\n            return Ok(Some(StoredResource::File { path: file_path }));\n        }\n        if let Some(metadata) = link_metadata {\n            if is_symlink_or_reparse(&metadata) || !metadata.is_file() {\n                bail!(\"staged symlink specification is not a regular file\");\n            }\n            let target = std::fs::read_to_string(&link_path)?;\n            if hash_tagged(b\"symlink\", target.as_bytes()) != expected_hash {\n                bail!(\"staged symlink hash mismatch\");\n            }\n            return Ok(Some(StoredResource::Symlink {\n                target: ExternalProfilePath::new(target)?,\n            }));\n        }\n        Ok(None)\n    }\n\n    fn capture_backup(root: &Path, operation_id: &str, target: &Path) -> anyhow::Result<()> {\n        match std::fs::symlink_metadata(target) {\n            Ok(metadata) if metadata.file_type().is_symlink() => {\n                let link_target = std::fs::read_link(target)?;\n                let link_target = link_target\n                    .to_str()","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/service/profile_file.rs#L772-L808","documentation":"read_staged_resource found a staged symlink-spec file, but that spec file itself is not a regular file (it is a symlink/reparse point, directory, or other non-regular node). The symlink target string is stored in a plain spec file; if the spec file was replaced by a link or other node, the code refuses to read it to avoid following untrusted paths.","triggerScenarios":"stage_link_path(root, operation_id) exists but symlink_metadata shows it is a symlink/reparse point or not a regular file — the spec file was replaced/tampered with, or the staging filesystem reports it as a special node.","commonSituations":"Manual manipulation of the staging dir; tools that convert spec files into links; unusual filesystems (reparse points on Windows, network mounts) hosting the staging root.","solutions":["Delete the non-regular node at the staged link-spec path and re-run materialization to rewrite it as a regular file.","Keep the staging root on a local, plain filesystem rather than network shares or containers' overlay volumes.","Check that no background tool (sync/backup/AV) is rewriting files in the staging directory as symlinks."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let md = std::fs::symlink_metadata(staged_link_path)?;\nif md.is_symlink() || !md.is_file() {\n    std::fs::remove_file(staged_link_path)?;\n}","typeGuard":"fn is_regular_file_node(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| !m.is_symlink() && m.is_file()).unwrap_or(false)\n}","tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"symlink specification is not a regular file\") => {\n        remove_stale_staging(root, op_id)?;\n        retry()\n    }\n    other => other,\n}","preventionTips":["Keep staging on plain local storage.","Don't hand-edit or replace spec files in the staging directory.","Watch for AV/sync tools that convert stored files into placeholders/links."],"tags":["filesystem","symlink","profile-materialization","rust"],"backgroundTag":"unsupported-operation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}