{"record":{"id":"7b44af5429c11e96","repo":"jdx/mise","slug":"copy-link-must-be-a-relative-path-within-the-sourc","errorCode":null,"errorMessage":"copy_link must be a relative path within the source: {}","messagePattern":"copy_link must be a relative path within the source: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote.rs","lineNumber":843,"sourceCode":"fn validate_copy_link(source: &Path, link: &Path) -> Result<()> {\n    validate_copy_link_path(source, link)?;\n    let path = source.join(link);\n    fs::metadata(&path)\n        .wrap_err_with(|| format!(\"copy_link target does not exist: {}\", link.display()))?;\n    Ok(())\n}\n\nfn validate_copy_link_path(source: &Path, link: &Path) -> Result<()> {\n    if link.as_os_str().is_empty()\n        || link.is_absolute()\n        || link.components().any(|component| {\n            matches!(\n                component,\n                Component::ParentDir | Component::RootDir | Component::Prefix(_)\n            )\n        })\n    {\n        bail!(\n            \"copy_link must be a relative path within the source: {}\",\n            link.display()\n        );\n    }\n    let mut parent = source.to_path_buf();\n    for component in link.parent().unwrap_or_else(|| Path::new(\"\")).components() {\n        if let Component::Normal(component) = component {\n            parent.push(component);\n            let metadata = fs::symlink_metadata(&parent).wrap_err_with(|| {\n                format!(\"copy_link parent does not exist: {}\", parent.display())\n            })?;\n            if metadata.file_type().is_symlink() {\n                bail!(\n                    \"copy_link cannot be nested below a symbolic link: {}\",\n                    link.display()\n                );\n            }\n        }","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote.rs#L825-L861","documentation":"When `copy_link` entries are configured for a remote source, each must be a relative path that stays inside the source directory and names a symbolic link. This error fires when the given link path is empty, absolute, or contains `..`, root, or prefix components, which would make the copy escape the source. mise rejects it before touching any files.","triggerScenarios":"Configuring a RemoteHost with copy_link containing e.g. \"/abs/link\", \"../link\", \"\", or a path with ParentDir/RootDir/Prefix components; validation runs in validate_copy_link_path during upload_source.","commonSituations":"User pastes an absolute path of the symlink instead of one relative to the source directory; a config with `../shared/link` intended to point outside the project; an empty copy_link setting combined with copy_links=false.","solutions":["Rewrite the copy_link value as a path relative to the source directory (e.g. `.claude` instead of `/home/me/project/.claude`)","Remove any `..` segments by restructuring the link inside the project","If the symlink lives outside the source, create an in-project symlink to it and reference that instead","Use copy_links=true to copy all links if per-link selection is not needed"],"exampleFix":"// before\ncopy_link = \"/home/me/project/.claude\"\n// after\ncopy_link = \".claude\"","handlingStrategy":"validation","validationCode":"// Rust-side preflight mirroring mise's rule\nfn is_valid_copy_link(link: &Path) -> bool {\n    !link.as_os_str().is_empty()\n        && !link.is_absolute()\n        && !link.components().any(|c| matches!(c,\n            std::path::Component::ParentDir\n            | std::path::Component::RootDir\n            | std::path::Component::Prefix(_)))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write copy_link values relative to the source directory","Never use absolute paths or `..` in copy_link entries","Run a config lint in CI that rejects copy_link values outside the project"],"tags":["path-validation","symlink","config"],"backgroundTag":"path-traversal-blocked","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}