{"record":{"id":"3611e07fae83796b","repo":"affaan-m/ECC","slug":"samples-cannot-be-empty","errorCode":null,"errorMessage":"samples cannot be empty","messagePattern":"samples cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/harness_eval.rs","lineNumber":522,"sourceCode":"\nimpl PromotionPolicy {\n    pub fn validate(self) -> Result<()> {\n        if self.min_samples == 0 {\n            bail!(\"minimum samples must be positive\");\n        }\n        if !self.min_mean_delta.is_finite() {\n            bail!(\"minimum mean delta must be finite\");\n        }\n        if !self.min_win_rate.is_finite() || !(0.0..=1.0).contains(&self.min_win_rate) {\n            bail!(\"minimum win rate must be between 0 and 1\");\n        }\n        Ok(())\n    }\n\n    pub fn compare(self, samples: &[PairedSample]) -> Result<Comparison> {\n        self.validate()?;\n        if samples.is_empty() {\n            bail!(\"samples cannot be empty\");\n        }\n        if samples\n            .iter()\n            .map(|sample| sample.seed)\n            .collect::<BTreeSet<_>>()\n            .len()\n            != samples.len()\n        {\n            bail!(\"sample seeds must be unique\");\n        }\n        if samples.iter().any(|s| {\n            !s.candidate_score.is_finite()\n                || !s.baseline_score.is_finite()\n                || !(0.0..=1.0).contains(&s.candidate_score)\n                || !(0.0..=1.0).contains(&s.baseline_score)\n        }) {\n            bail!(\"scores must be finite and between 0 and 1\");\n        }","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/harness_eval.rs#L504-L540","documentation":"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()`).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nlet result = evaluator.compare(&samples)?;\n// after\nanyhow::ensure!(!samples.is_empty(), \"no samples collected for comparison\");\nlet result = evaluator.compare(&samples)?;","handlingStrategy":"validation","validationCode":"if samples.is_empty() {\n    return Err(anyhow::anyhow!(\"no samples collected; cannot compare\"));\n}","typeGuard":null,"tryCatchPattern":"match evaluator.compare(&samples) {\n    Ok(c) => c,\n    Err(e) if e.to_string().contains(\"samples cannot be empty\") => {\n        eprintln!(\"Skipping comparison: no samples collected\");\n        return Ok(());\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["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"],"tags":["validation","empty-input","evaluation-harness"],"backgroundTag":"empty-required-field","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}