Hmbown/CodeWhale · error

artifact tree exceeds export depth limit

Error message

artifact tree exceeds export depth limit

What it means

collect_artifact_files_recursive walks the session's artifacts directory to gather files for a tar export, and refuses to descend deeper than MAX_ARTIFACT_DEPTH. Hitting the limit means the artifact tree is pathologically deep, so the export aborts with InvalidData instead of recursing unboundedly (which would risk stack exhaustion on adversarial trees).

Solutions

  1. Find and flatten the over-deep subtree under the session's artifacts/ directory.
  2. Move genuinely deep content out of artifacts/ (store an archive instead of a deep tree).
  3. Check what wrote the deep tree and cap its nesting depth at the source.
  4. If legitimate content truly needs more depth, raise MAX_ARTIFACT_DEPTH deliberately and document the change.

Example fix

// before
# artifacts/run-1/a/b/c/d/e/f/g/... (100 levels deep)
// after
$ tar -cf deep.tar -C artifacts/run-1 . && rm -rf artifacts/run-1/a
$ mkdir artifacts/run-1 && mv deep.tar artifacts/run-1/bundle.tar
Defensive patterns

Strategy: validation

Validate before calling

fn tree_depth_under(dir: &Path, max: usize) -> std::io::Result<bool> {
    fn walk(d: &Path, depth: usize, max: usize) -> std::io::Result<bool> {
        if depth > max { return Ok(false); }
        for e in std::fs::read_dir(d)? {
            let e = e?;
            if e.file_type()?.is_dir() && !walk(&e.path(), depth + 1, max)? { return Ok(false); }
        }
        Ok(true)
    }
    walk(dir, 0, max)
}

Prevention

When it happens

Trigger: Exporting a session whose artifacts/<subtree> nesting exceeds MAX_ARTIFACT_DEPTH levels, e.g. a tool wrote deeply nested output under the artifacts dir, or an adversarially crafted session directory is exported.

Common situations: A build tool or generator created hundreds of nested directories inside artifacts/; a user copied a deep project tree into the artifacts folder; a malicious/corrupted session directory designed to blow up the exporter.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/449e774964865849. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/session_export.rs:339

        ARTIFACTS_DIR_NAME,
        0,
        &mut entries,
        &mut files,
    )?;
    files.sort_by(|left, right| left.0.cmp(&right.0));
    Ok(files)
}

fn collect_artifact_files_recursive(
    sessions_dir: &Path,
    dir: &Path,
    prefix: &str,
    depth: usize,
    entries: &mut usize,
    files: &mut Vec<(String, PathBuf)>,
) -> io::Result<()> {
    if depth > MAX_ARTIFACT_DEPTH {
        return Err(io::Error::new(
            io::ErrorKind::InvalidData,
            "artifact tree exceeds export depth limit",
        ));
    }
    for entry in fs::read_dir(dir)? {
        let entry = entry?;
        *entries += 1;
        if *entries > MAX_ARTIFACT_ENTRIES {
            return Err(io::Error::new(
                io::ErrorKind::InvalidData,
                "artifact tree exceeds export entry limit",
            ));
        }
        let file_type = entry.file_type()?;
        if file_type.is_symlink() {
            continue;
        }
        let child = entry.file_name();

View on GitHub (pinned to 73e0f67d83)