astrid-runtime/astrid · error

unsafe capsule path

Error message

unsafe capsule path '{}'

What it means

Fired by normalize_relative_path when a relative path within a capsule content tree contains a non-Normal component (ParentDir, RootDir, or Prefix), i.e. it would escape or be absolute. Generic path-safety guard over user-supplied tree paths.

Solutions

  1. Fix the content tree so all paths are relative and stay under the capsule root
  2. Remove symlinks or `..` references from the content directory
  3. Rebuild the capsule
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/astrid-build/src/artifact.rs:522 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/6d9c7ef1add4ca03. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-build/src/artifact.rs:522

        let mut file = File::open(&path)?;
        let size = file.metadata()?.len();
        records.push(hash_reader(normalized, size, &mut file)?);
    }
    Ok(())
}

fn normalize_relative_path(path: &Path) -> anyhow::Result<String> {
    let mut parts = Vec::new();
    for component in path.components() {
        match component {
            Component::Normal(part) => parts.push(
                part.to_str()
                    .context("capsule paths must be UTF-8")?
                    .to_string(),
            ),
            Component::CurDir => {},
            Component::ParentDir | Component::RootDir | Component::Prefix(_) => {
                bail!("unsafe capsule path '{}'", path.display());
            },
        }
    }
    Ok(parts.join("/"))
}

#[cfg(test)]
mod tests {
    use super::*;

    #[cfg(windows)]
    struct FreshWindowsHome {
        path: std::path::PathBuf,
    }

    #[cfg(windows)]
    impl FreshWindowsHome {
        fn new() -> Self {

View on GitHub (pinned to affd8760f4)