zed-industries/zed · error

only one split can use 'rest'

Error message

only one split can use 'rest'

What it means

Bailed while computing split sizes for `ep split`: more than one split spec used the `=rest` size. `rest` means 'whatever remains after all other splits are satisfied', which is only well-defined for a single split, so a second occurrence is rejected before any lines are distributed.

Source

Thrown at crates/edit_prediction_cli/src/split_dataset.rs:187

fn compute_split_counts(specs: &[SplitSpec], total: usize) -> Result<Vec<usize>> {
    let mut counts = vec![0usize; specs.len()];
    let mut remaining = total;
    let mut rest_index: Option<usize> = None;

    for (i, spec) in specs.iter().enumerate() {
        match &spec.size {
            SplitSize::Percentage(pct) => {
                let count = (total as f64 * pct).round() as usize;
                counts[i] = count.min(remaining);
                remaining = remaining.saturating_sub(counts[i]);
            }
            SplitSize::Absolute(count) => {
                counts[i] = (*count).min(remaining);
                remaining = remaining.saturating_sub(counts[i]);
            }
            SplitSize::Rest => {
                if rest_index.is_some() {
                    bail!("only one split can use 'rest'");
                }
                rest_index = Some(i);
            }
        }
    }

    if let Some(idx) = rest_index {
        counts[idx] = remaining;
    }

    Ok(counts)
}

fn write_lines_to_file(path: &Path, lines: &[String]) -> Result<()> {
    if let Some(parent) = path.parent() {
        if !parent.as_os_str().is_empty() {
            std::fs::create_dir_all(parent)
                .with_context(|| format!("failed to create directory '{}'", parent.display()))?;

View on GitHub (pinned to f4178619ac)

Solutions

  1. Give all but one split an explicit percentage or absolute count
  2. Keep `=rest` on the single split that should absorb leftovers

Example fix

# before
ep split data.jsonl train.jsonl=80% dev.jsonl=rest test.jsonl=rest

# after
ep split data.jsonl train.jsonl=80% dev.jsonl=10% test.jsonl=rest
Defensive patterns

Strategy: validation

Validate before calling

let rest_count = specs.iter().filter(|s| s.ends_with("=rest")).count();
if rest_count > 1 {
    // reject before running: only one split may claim the remainder
}

Try / catch

Count `=rest` occurrences across the spec list up front and fail with a clear message naming the duplicate splits.

Prevention

When it happens

Trigger: Running `ep split data.jsonl train.jsonl=80% valid.jsonl=rest test.jsonl=rest` — two specs claiming the remainder.

Common situations: Copy-pasting a `=rest` spec when adding an extra split; adapting a two-way split template to three-way without converting one rest to an explicit size.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/6e417c4a56071dbc. Report an issue: GitHub.