Skip to content

fix: subgraph create should deduplicated bindings on name conflict#2110

Open
maxy-shpfy wants to merge 1 commit into04-21-fix_import_pipeline_in_v2_should_navigate_to_a_proper_filefrom
04-21-fix_subgraph_create_should_deduplicated_bindings_on_name_conflict
Open

fix: subgraph create should deduplicated bindings on name conflict#2110
maxy-shpfy wants to merge 1 commit into04-21-fix_import_pipeline_in_v2_should_navigate_to_a_proper_filefrom
04-21-fix_subgraph_create_should_deduplicated_bindings_on_name_conflict

Conversation

@maxy-shpfy
Copy link
Copy Markdown
Collaborator

@maxy-shpfy maxy-shpfy commented Apr 22, 2026

Description

Closes #2123

Fixes two bugs in the createSubgraph action and adds comprehensive roundtrip tests to verify correctness of createSubgraph followed by unpackSubgraph.

Bug 1 – Duplicate port names when grouping external bindings: When multiple external bindings targeted different selected tasks but shared the same port name (e.g., two tasks both receiving a trainer_name input), the subgraph would generate duplicate input/output port names. A deduplicatePortName helper is introduced to append a numeric suffix (_2, _3, …) when a name collision is detected, preventing ghost or duplicate bindings after an unpack.

Bug 2 – executionOptions not preserved through subgraph creation: Task executionOptions (caching strategy, retry strategy, etc.) were not included in the task snapshot taken during createSubgraph, causing them to be silently dropped. The snapshot and task reconstruction now carry executionOptions through correctly.

Related Issue and Pull requests

Type of Change

  • Bug fix
  • New feature

Checklist

  • I have tested this does not break current pipelines / runs functionality
  • I have tested the changes on staging

Test Instructions

The new test suite in unpackSubgraph.test.ts covers the following scenarios and can be run directly:

  1. Single task roundtrip preserves task count and componentRef.
  2. Two connected tasks roundtrip preserves binding connectivity.
  3. External incoming and outgoing bindings are preserved after roundtrip.
  4. Complex graphs with inputs, outputs, and branching produce no ghost or extra bindings.
  5. executionOptions with maxCacheStaleness, retryStrategy, or both are preserved.
  6. isEnabled predicates are preserved.
  7. Static arguments are preserved.
  8. No ghost bindings remain after unpack (all binding endpoints reference real entities).
  9. No duplicate bindings when different external sources feed same-named ports on different selected tasks.

Additional Comments

The deduplicatePortName helper is intentionally simple: it tries the base name first, then appends _2, _3, etc. This matches the convention used elsewhere in the codebase for name collision resolution.

@github-actions
Copy link
Copy Markdown

🎩 Preview

A preview build has been created at: 04-21-fix_subgraph_create_should_deduplicated_bindings_on_name_conflict/ead165b

Comment on lines +290 to +300
function deduplicatePortName(baseName: string, usedNames: Set<string>): string {
if (!usedNames.has(baseName)) {
usedNames.add(baseName);
return baseName;
}
let counter = 2;
while (usedNames.has(`${baseName}_${counter}`)) counter++;
const unique = `${baseName}_${counter}`;
usedNames.add(unique);
return unique;
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could this run into conflicts if the a port(s) already have names in the form name_number?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the while loop may catch this. but worth keeping an eye out once in the wild

Copy link
Copy Markdown
Collaborator

@camielvs camielvs left a comment

Choose a reason for hiding this comment

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

Issue appears to be fixed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants