affaan-m/ECC · error
samples cannot be empty
Error message
samples cannot be empty
What it means
The `compare` function of the harness evaluation module rejects an empty slice of `PairedSample` inputs before running any statistical comparison. It needs at least one paired candidate/baseline measurement to compute means, deltas, and win rates; dividing by zero samples would be undefined. The check runs after internal threshold validation (`self.validate()`).
Solutions
- Ensure at least one PairedSample is collected before calling compare.
- Check policy configuration so minimum sample count is > 0 and seed generation actually yields values.
- Guard the call site: return early or skip promotion evaluation when samples is empty.
Example fix
// before let result = evaluator.compare(&samples)?; // after anyhow::ensure!(!samples.is_empty(), "no samples collected for comparison"); let result = evaluator.compare(&samples)?;
Defensive patterns
Strategy: validation
Validate before calling
if samples.is_empty() {
return Err(anyhow::anyhow!("no samples collected; cannot compare"));
} Try / catch
match evaluator.compare(&samples) {
Ok(c) => c,
Err(e) if e.to_string().contains("samples cannot be empty") => {
eprintln!("Skipping comparison: no samples collected");
return Ok(());
}
Err(e) => return Err(e),
} Prevention
- Assert sample collection produced entries before evaluation
- Log the sample count at collection time
- Set a minimum sample count in the eval policy and enforce it upstream
When it happens
Trigger: Calling `compare(&[])` (or `compare` with a Vec built from a filter that removed all samples), e.g. when a caller's seed generation or sampling loop produced no entries.
Common situations: Test harness runs where all samples were filtered out (e.g. all seeds skipped), a config file with an empty samples list, or a collection step that silently produced an empty vec before evaluation.
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
- at least one explicit seed is required
- At least one guided harness must be selected
- at least one non-empty
- at least one placement is required
- At least one video is required
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/3611e07fae83796b.
Report an issue: GitHub.
Appendix: source
Thrown at ecc2/src/harness_eval.rs:522
impl PromotionPolicy {
pub fn validate(self) -> Result<()> {
if self.min_samples == 0 {
bail!("minimum samples must be positive");
}
if !self.min_mean_delta.is_finite() {
bail!("minimum mean delta must be finite");
}
if !self.min_win_rate.is_finite() || !(0.0..=1.0).contains(&self.min_win_rate) {
bail!("minimum win rate must be between 0 and 1");
}
Ok(())
}
pub fn compare(self, samples: &[PairedSample]) -> Result<Comparison> {
self.validate()?;
if samples.is_empty() {
bail!("samples cannot be empty");
}
if samples
.iter()
.map(|sample| sample.seed)
.collect::<BTreeSet<_>>()
.len()
!= samples.len()
{
bail!("sample seeds must be unique");
}
if samples.iter().any(|s| {
!s.candidate_score.is_finite()
|| !s.baseline_score.is_finite()
|| !(0.0..=1.0).contains(&s.candidate_score)
|| !(0.0..=1.0).contains(&s.baseline_score)
}) {
bail!("scores must be finite and between 0 and 1");
}View on GitHub (pinned to 8321021c54)