{"record":{"id":"6a5aad0707dff137","repo":"zed-industries/zed","slug":"percentage-must-be-between-0-and-100-got","errorCode":null,"errorMessage":"percentage must be between 0 and 100, got {}","messagePattern":"percentage must be between 0 and 100, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/edit_prediction_cli/src/split_dataset.rs","lineNumber":135,"sourceCode":"pub struct SplitSpec {\n    pub path: PathBuf,\n    pub size: SplitSize,\n}\n\nfn parse_split_spec(spec: &str) -> Result<SplitSpec> {\n    let (path, size_str) = spec\n        .rsplit_once('=')\n        .with_context(|| format!(\"invalid split spec '{}': expected <path>=<size>\", spec))?;\n\n    let size = if size_str == \"rest\" {\n        SplitSize::Rest\n    } else if size_str.ends_with('%') {\n        let pct_str = size_str.trim_end_matches('%');\n        let pct: f64 = pct_str\n            .parse()\n            .with_context(|| format!(\"invalid percentage '{}' in '{}'\", pct_str, spec))?;\n        if !(0.0..=100.0).contains(&pct) {\n            bail!(\"percentage must be between 0 and 100, got {}\", pct);\n        }\n        SplitSize::Percentage(pct / 100.0)\n    } else {\n        let count: usize = size_str\n            .parse()\n            .with_context(|| format!(\"invalid count '{}' in '{}'\", size_str, spec))?;\n        SplitSize::Absolute(count)\n    };\n\n    Ok(SplitSpec {\n        path: PathBuf::from(path),\n        size,\n    })\n}\n\nfn read_lines_from_input(input: Option<&Path>) -> Result<Vec<String>> {\n    let reader: Box<dyn BufRead> = match input {\n        Some(path) => {","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/edit_prediction_cli/src/split_dataset.rs#L117-L153","documentation":"Bailed while parsing a `ep split` spec like `train.jsonl=80%`: the percentage parsed as a number but fell outside the inclusive 0–100 range. Percentages are whole-range values (80 means 80%, not 0.8), and values are validated before any file is read.","triggerScenarios":"Passing `train.jsonl=120%`, `valid.jsonl=-5%`, or `train.jsonl=0.8%` (fraction expressed as if it were a percentage) to `ep split`.","commonSituations":"Assuming percentages are fractions (0.8 instead of 80); three-way splits accidentally summing over 100; typos.","solutions":["Keep each percentage in 0–100 inclusive","Express fractional intent as 80, not 0.8","Use the `rest` keyword on one split to absorb leftovers instead of forcing percentages to sum exactly"],"exampleFix":"# before\nep split data.jsonl train.jsonl=0.8 valid.jsonl=0.2\n\n# after\nep split data.jsonl train.jsonl=80% valid.jsonl=20%","handlingStrategy":"validation","validationCode":"fn is_valid_percentage(text: &str) -> bool {\n    text.strip_suffix('%')\n        .and_then(|t| t.parse::<f64>().ok())\n        .map(|p| (0.0..=100.0).contains(&p))\n        .unwrap_or(false)\n}","typeGuard":"fn is_valid_percentage(text: &str) -> bool {\n    text.strip_suffix('%')\n        .and_then(|t| t.parse::<f64>().ok())\n        .map(|p| (0.0..=100.0).contains(&p))\n        .unwrap_or(false)\n}","tryCatchPattern":"Validate every `<path>=<size>` spec string before invoking the split command; report all invalid specs at once instead of failing on the first.","preventionTips":["Range-check percentages client-side before building the command line","Remember percentages are 0-100, not fractions","Use rest for leftovers instead of computing 100 minus others by hand"],"tags":["cli","argument-validation","percentage","rust"],"backgroundTag":"argument-out-of-range","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}