{"record":{"id":"3d1609c6c385dd67","repo":"astrid-runtime/astrid","slug":"corpus-name-contains-no-regular-files","errorCode":null,"errorMessage":"corpus {name:?} contains no regular files","messagePattern":"corpus (.+?) contains no regular files","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-storage-chunker-evidence/src/corpus.rs","lineNumber":319,"sourceCode":"            }\n            input.validate_current_file()?;\n        }\n        black_box(guard);\n        Ok(elapsed)\n    }\n\n    fn logical_bytes(&self) -> Result<u64> {\n        self.inputs.iter().try_fold(0_u64, |total, input| {\n            total\n                .checked_add(input.logical_bytes())\n                .ok_or_else(|| anyhow::anyhow!(\"corpus logical byte count overflow\"))\n        })\n    }\n\n    fn from_files(name: String, kind: CorpusKind, inputs: Vec<Input>) -> Result<Self> {\n        validate_label(&name)?;\n        if inputs.is_empty() {\n            bail!(\"corpus {name:?} contains no regular files\");\n        }\n        Ok(Self { name, kind, inputs })\n    }\n}\n\nfn measure_reader<R: Read>(\n    reader: R,\n    logical_bytes: u64,\n    candidate: &Candidate,\n    hash_records: bool,\n    guard: &mut [u8; 32],\n) -> Result<u64> {\n    let mut reader = CountingReader::new(reader);\n    if logical_bytes <= u64::from(candidate.maximum_bytes) {\n        let mut buffer = vec![0_u8; READER_CAPACITY];\n        let mut hasher = hash_records.then(blake3::Hasher::new);\n        loop {\n            let read = reader.read(&mut buffer)?;","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-storage-chunker-evidence/src/corpus.rs#L301-L337","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a corpus directory that actually contains regular files, or add `--git-history`/`--corpus` entries pointing at real files","Check that the directory is not empty and contains regular files (`find <dir> -maxdepth 1 -type f | head`)","If intentionally measuring synthetic data only, omit the corpus option instead of `--no-synthetic` with nothing else selected"],"exampleFix":"// before\nlet corpus = Corpus::from_directory(\"empty\", CorpusKind::Captured, &empty_dir)?;\n// after\nassert!(empty_dir.read_dir()?.next().is_some(), \"corpus dir must contain files\");\nlet corpus = Corpus::from_directory(\"empty\", CorpusKind::Captured, &nonempty_dir)?;","handlingStrategy":"validation","validationCode":"fn has_regular_files(dir: &Path) -> bool {\n    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)\n}\n// call before constructing the corpus: assert!(has_regular_files(&dir))","typeGuard":"fn corpus_inputs_nonempty(inputs: &[Input]) -> bool { !inputs.is_empty() }","tryCatchPattern":"match Corpus::from_directory(name, kind, dir) {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"contains no regular files\") => {\n        eprintln!(\"corpus dir {dir:?} is empty; skipping\"); return;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Assert the directory has at least one regular file before building a corpus","Avoid pointing corpora at empty mount points or filtered directories","Log the number of collected inputs so empty collections surface early"],"tags":["rust","corpus","empty-input","validation"],"backgroundTag":"empty-required-field","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}