zed-industries/zed · error

invalid relative path component: {component:?}

Error message

invalid relative path component: {component:?}

What it means

RelPathBuf::push_component rejected the component because it is empty, contains '/', or equals '.' or '..'. Components must be single path segments so that pushing preserves the normalized-relative invariant of the buffer.

Source

Thrown at crates/path/src/rel_path.rs:358

            self.0.clear();
            true
        } else {
            false
        }
    }

    pub fn push(&mut self, path: &RelPath) {
        if path.is_empty() {
            return;
        }
        if !self.is_empty() {
            self.0.push('/');
        }
        self.0.push_str(&path.0);
    }

    pub fn push_component(&mut self, component: &str) -> Result<()> {
        anyhow::ensure!(
            !component.is_empty()
                && !component.contains('/')
                && component != "."
                && component != "..",
            "invalid relative path component: {component:?}"
        );

        if !self.is_empty() {
            self.0.push('/');
        }
        self.0.push_str(component);
        Ok(())
    }

    pub fn as_rel_path(&self) -> &RelPath {
        RelPath::from_str(self.0.as_str())
    }

View on GitHub (pinned to f4178619ac)

Solutions

  1. Split multi-segment inputs and push each segment separately
  2. Sanitize user-derived strings (e.g. names, ids used as path segments) before pushing
  3. Reject empty or traversal components at the input boundary
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/path/src/rel_path.rs:358 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/7b40413016e50f34. Report an issue: GitHub.