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
- Rename one of the colliding jobs so every name within a section is unique.
- If the duplicate is intentional, move the second entry to a different section (e.g. optional-) or merge their configs.
- Search the config for the reported name and remove the stale block.
- 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
- Lint job-config YAML for per-section name uniqueness in CI.
- Rename rather than copy-paste job blocks.
- Run citool validation locally before pushing.
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
- PR job `{}` differs from corresponding Auto job `{}` in conf
- Auto job `{job}` cannot have `continue_on_error: true`. If t
- Patterns `{}` did not match any auto jobs
- It is only possible to schedule up to {MAX_TRY_JOBS_COUNT} c
- config key {} not in sections or top_level_keys
AI-assisted analysis of rust-lang/rust@7088e4b63a (2026-08-10).
Data as JSON: /api/errors/1edead24effe4d6b.
Report an issue: GitHub.