Hmbown/CodeWhale · error · anyhow::Error

workspace appears empty after File.list

Error message

workspace appears empty after File.list: {}

What it means

summarize_workspace runs a File.list over the eval workspace. If the resulting file list is empty even though the File.list tool produced non-empty output, the workspace state and the tool output disagree — an invariant violation. It fails loudly rather than summarizing an apparently empty workspace.

Solutions

  1. Check the File.list output embedded in the error message for format anomalies.
  2. Verify the workspace root directory actually contains files.
  3. Confirm the parsing of File.list output matches the tool's current output format.
Defensive patterns

Strategy: validation

Validate before calling

if !std::path::Path::new(workspace_root).read_dir().map(|mut d| d.next().is_some()).unwrap_or(false) {
    eprintln!("workspace root is empty before eval; setup step failed?");
}

Try / catch

match summarize_workspace(...) {
    Err(e) if e.to_string().starts_with("workspace appears empty") => {
        log::error!("File.list output parsed to zero files; check output format");
    }
    other => other?,
}

Prevention

When it happens

Trigger: run() calls summarize_workspace and File.list returns text output but files.collect() ends up empty (e.g. output format mismatch causing parse to yield no entries).

Common situations: File.list output format changed or was truncated so the parser silently matched zero files; workspace root pointed somewhere unexpected while the tool listed a different directory.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


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

Appendix: source

Thrown at crates/tui/src/eval.rs:550

    let walker = WalkBuilder::new(root)
        .hidden(false)
        .git_ignore(false)
        .git_global(false)
        .git_exclude(false)
        .build();

    for entry in walker {
        let entry = entry.with_context(|| format!("failed to walk {}", root.display()))?;
        if entry.file_type().is_some_and(|t| t.is_file()) {
            files.push(entry.into_path());
        }
    }

    if files.is_empty()
        && let Some(output) = list_output
        && !output.trim().is_empty()
    {
        return Err(anyhow!(
            "workspace appears empty after File.list: {}",
            output.trim()
        ));
    }

    files.sort();

    Ok(WorkspaceSummary {
        root: root.to_path_buf(),
        file_count: files.len(),
        files,
    })
}

fn validate_outputs(
    root: &Path,
    shell_expect_token: &str,
    search_output: Option<&str>,

View on GitHub (pinned to 73e0f67d83)