astrid-runtime/astrid · error

corpus {name:?} contains no regular files

Error message

corpus {name:?} contains no regular files

What it means

Corpus construction requires at least one regular input file; `from_files` bails out when the collected `inputs` vector is empty. The library deliberately refuses to baseline an empty corpus because all downstream evidence measurements (chunker throughput, dedup ratios) would be meaningless.

Source

Thrown at crates/astrid-storage-chunker-evidence/src/corpus.rs:319

            }
            input.validate_current_file()?;
        }
        black_box(guard);
        Ok(elapsed)
    }

    fn logical_bytes(&self) -> Result<u64> {
        self.inputs.iter().try_fold(0_u64, |total, input| {
            total
                .checked_add(input.logical_bytes())
                .ok_or_else(|| anyhow::anyhow!("corpus logical byte count overflow"))
        })
    }

    fn from_files(name: String, kind: CorpusKind, inputs: Vec<Input>) -> Result<Self> {
        validate_label(&name)?;
        if inputs.is_empty() {
            bail!("corpus {name:?} contains no regular files");
        }
        Ok(Self { name, kind, inputs })
    }
}

fn measure_reader<R: Read>(
    reader: R,
    logical_bytes: u64,
    candidate: &Candidate,
    hash_records: bool,
    guard: &mut [u8; 32],
) -> Result<u64> {
    let mut reader = CountingReader::new(reader);
    if logical_bytes <= u64::from(candidate.maximum_bytes) {
        let mut buffer = vec![0_u8; READER_CAPACITY];
        let mut hasher = hash_records.then(blake3::Hasher::new);
        loop {
            let read = reader.read(&mut buffer)?;

View on GitHub (pinned to affd8760f4)

Solutions

  1. Pass a corpus directory that actually contains regular files, or add `--git-history`/`--corpus` entries pointing at real files
  2. Check that the directory is not empty and contains regular files (`find <dir> -maxdepth 1 -type f | head`)
  3. If intentionally measuring synthetic data only, omit the corpus option instead of `--no-synthetic` with nothing else selected

Example fix

// before
let corpus = Corpus::from_directory("empty", CorpusKind::Captured, &empty_dir)?;
// after
assert!(empty_dir.read_dir()?.next().is_some(), "corpus dir must contain files");
let corpus = Corpus::from_directory("empty", CorpusKind::Captured, &nonempty_dir)?;
Defensive patterns

Strategy: validation

Validate before calling

fn has_regular_files(dir: &Path) -> bool {
    std::fs::read_dir(dir).map(|rd| rd.filter_map(|e| e.ok()).any(|e| e.file_type().map(|t| t.is_file()).unwrap_or(false))).unwrap_or(false)
}
// call before constructing the corpus: assert!(has_regular_files(&dir))

Type guard

fn corpus_inputs_nonempty(inputs: &[Input]) -> bool { !inputs.is_empty() }

Try / catch

match Corpus::from_directory(name, kind, dir) {
    Ok(c) => c,
    Err(e) if e.to_string().contains("contains no regular files") => {
        eprintln!("corpus dir {dir:?} is empty; skipping"); return;
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `Corpus::from_directory` (or `from_files` via `Input` collection) on a directory containing no regular files, or passing an empty inputs list; directories containing only subdirectories, symlinks, or hidden filtered files also yield empty inputs.

Common situations: Pointing the CLI at an empty directory, a path filtered out by `validate_relative_git_path`, a mount point with no files, or a typo'd path that resolves to an empty dir rather than failing outright.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


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