Skip to content

fix: deduplicate workflow and job names#4606

Open
elias-ba wants to merge 7 commits intomainfrom
fix/dedup-workflow-names
Open

fix: deduplicate workflow and job names#4606
elias-ba wants to merge 7 commits intomainfrom
fix/dedup-workflow-names

Conversation

@elias-ba
Copy link
Copy Markdown
Contributor

@elias-ba elias-ba commented Apr 8, 2026

Description

This PR fixes AI-generated workflows failing to save when the workflow name collides with an existing one or when the AI generates jobs with duplicate names.

The root cause was that workflow name validation (ensure_unique_name) only ran in the manual import path (WorkflowEditor) but was skipped in the AI generation path (useAIWorkflowApplications). Instead of patching just the AI path, this centralizes both workflow name validation and job name deduplication inside importWorkflow in the workflow store, so all import paths (manual, template, AI) get it automatically.

Closes #4607

Validation steps

  1. Create a workflow via AI with a name that already exists in the project — name should auto-append " 1", " 2", etc.
  2. Create a workflow via AI where jobs have duplicate names — names should auto-deduplicate
  3. Import a workflow via YAML with a duplicate name — should still work as before
  4. Unit tests pass (84/84 across related test files)

Additional notes for the reviewer

None.

AI Usage

  • I have used Claude Code
  • I have used another model
  • I have not used AI

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

Workflow name validation and job name deduplication now happen centrally
inside importWorkflow, fixing AI-generated workflows that couldn't be
saved when they had a name collision with existing workflows or
duplicate job names.
@github-project-automation github-project-automation bot moved this to New Issues in Core Apr 8, 2026
@elias-ba elias-ba changed the title fix: deduplicate workflow and job names on import fix: deduplicate workflow and job names Apr 8, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.59%. Comparing base (baeb59a) to head (a876333).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4606      +/-   ##
==========================================
+ Coverage   89.54%   89.59%   +0.05%     
==========================================
  Files         441      441              
  Lines       21355    21355              
==========================================
+ Hits        19122    19133      +11     
+ Misses       2233     2222      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Covers workflow name validation via channel, job name deduplication,
graceful fallback when validation fails, and no-op for unique names.
Use a Set to track all used names (original + generated) instead of a
simple counter, so "Transform 2" is skipped when it already exists.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Security Review

⚠️ Automated security review did not complete.

Claude hit the max-turns limit or encountered an error before posting findings.
A manual review of S0 (project-scoped data access), S1 (authorization policies),
and S2 (audit trail coverage) is recommended for this PR.

See the workflow run for details.

elias-ba added 3 commits April 8, 2026 18:21
Add .catch() to the importWorkflow promise in WorkflowEditor to prevent
unhandled rejections. Extract makeJob, makeWorkflowState, and getJobNames
test helpers to reduce repetition in importWorkflow tests.
…union

Extract selectedContextJobId with an `in` type guard to safely access
job_id from the WorkflowTemplateContext discriminated union, fixing TS2339
errors and an eslint complex-expression warning.
Copy link
Copy Markdown
Collaborator

@theroinaochieng theroinaochieng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @elias-ba!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

[P3] AI-generated workflows can't be saved when name collides with existing workflow

2 participants