rust-lang/rust · error · anyhow::Error

duplicate job name `{job_name}` in section `{section}`

Error message

duplicate job name `{job_name}` in section `{section}`

What it means

citool builds a JobDatabase from the CI job YAML and runs validate_job_database (src/ci/citool/src/jobs.rs:144). ensure_no_duplicate_job_names rejects any job name that appears more than once within a single section — one of pr, auto, try, or optional. The duplicate name plus section name are reported.

Source

Thrown at src/ci/citool/src/jobs.rs:150

        // environment versus PR environment.
        if db.find_auto_job_by_name(&pr_job.name).is_some() {
            continue;
        }

        let auto_registered_job = Job { continue_on_error: Some(false), ..pr_job.clone() };
        db.auto_jobs.push(auto_registered_job);
    }

    Ok(())
}

fn validate_job_database(db: &JobDatabase) -> anyhow::Result<()> {
    fn ensure_no_duplicate_job_names(section: &str, jobs: &Vec<Job>) -> anyhow::Result<()> {
        let mut job_names = HashSet::new();
        for job in jobs {
            let job_name = job.name.as_str();
            if !job_names.insert(job_name) {
                return Err(anyhow::anyhow!(
                    "duplicate job name `{job_name}` in section `{section}`"
                ));
            }
        }
        Ok(())
    }

    ensure_no_duplicate_job_names("pr", &db.pr_jobs)?;
    ensure_no_duplicate_job_names("auto", &db.auto_jobs)?;
    ensure_no_duplicate_job_names("try", &db.try_jobs)?;
    ensure_no_duplicate_job_names("optional", &db.optional_jobs)?;

    fn equivalent_modulo_carve_out(pr_job: &Job, auto_job: &Job) -> anyhow::Result<()> {
        let Job {
            name,
            os,
            only_on_channel,
            free_disk,

View on GitHub (pinned to 7088e4b63a)

Solutions

  1. Rename one of the colliding jobs so every name within a section is unique.
  2. If the duplicate is intentional, move the second entry to a different section (e.g. optional-) or merge their configs.
  3. Search the config for the reported name and remove the stale block.
  4. Add a local pre-commit check that asserts uniqueness per section.

Example fix

# before
pr_jobs:
  - name: x86_64-gnu
    ...
  - name: x86_64-gnu   # duplicate -> error
    ...

# after
pr_jobs:
  - name: x86_64-gnu
    ...
  - name: x86_64-gnu-debug
    ...
Defensive patterns

Strategy: validation

Validate before calling

use std::collections::HashSet;
fn ensure_unique(section: &str, names: &[String]) -> Result<(), String> {
    let mut seen = HashSet::new();
    for n in names {
        if !seen.insert(n.clone()) {
            return Err(format!("duplicate job name `{n}` in section `{section}`"));
        }
    }
    Ok(())
}
// Run ensure_unique on each section before submitting the config.

Prevention

When it happens

Trigger: Editing rust-ci.yml or the job-definition files so that two jobs in the same section (pr_jobs/auto_jobs/try_jobs/optional_jobs) share an identical name key.

Common situations: Copy-pasting a job block and forgetting to rename it; merging two config files that both define a job; refactoring that moves a job between sections but leaves the old entry.

Related errors


AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10). Data as JSON: /api/errors/1edead24effe4d6b. Report an issue: GitHub.