Skip to content

fix(cli): prevent AsyncAPI channel name collisions when merging multiple specs#12325

Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770963428-fix-asyncapi-channel-collision
Closed

fix(cli): prevent AsyncAPI channel name collisions when merging multiple specs#12325
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1770963428-fix-asyncapi-channel-collision

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

Description

Refs: Customer issue where Lightning v2 WebSocket endpoint was missing from docs when two AsyncAPI specs with the same x-fern-sdk-group-name (e.g., both "Text to Speech") were included in one API definition.

When multiple AsyncAPI specs produce the same channel ID (derived from x-fern-sdk-group-name), the spread merge {...channels1, ...channels2} silently overwrites the first channel. This PR adds collision detection with suffix-based deconfliction (_1, _2, etc.) across all three merge paths.

Link to Devin run | Requested by @willkendall01

Changes Made

  • openapi-ir-parser/src/parse.ts: Replaced spread merges with a new mergeChannels() helper that detects ID collisions and appends numeric suffixes. Applied in the inline AsyncAPI parse loop and all 3 return paths of the merge() function.
  • v3-importer-commons/AbstractSpecConverter.ts: In addWebsocketChannelToIr, detect when the computed channelName already exists in this.ir.websocketChannels. On collision, fall back to the path-based default name with a suffix. Also reassigns the package if the existing package already has a different websocket channel.
  • ir-utils/mergeIntermediateRepresentation.ts: In mergeServicesAndChannels, iterate ir2 channels with collision detection instead of spread-merging. Tracks renamed channel IDs and updates subpackage/rootPackage .websocket references to point to the new IDs.
  • cli/versions.yml: Added 3.76.1 changelog entry.

Testing

  • Unit tests added/updated
  • Biome lint passes on all changed files
  • Manual testing completed

⚠️ Key Review Points

  1. No unit tests: Collision logic is untested. Consider whether a test with two AsyncAPI specs sharing the same x-fern-sdk-group-name should be added.
  2. Mutation of ir2 in mergeIntermediateRepresentation.ts (lines 410-418): Subpackage and rootPackage .websocket references are mutated in place on ir2. Verify ir2 is not referenced after the merge call.
  3. parse.ts mergeChannels does not update group/package references: Unlike the IR merge which updates subpackage refs, the OpenAPI IR merge only renames the channel key. Confirm that nothing in the OpenAPI IR layer references channels by ID downstream.
  4. Package fallback in AbstractSpecConverter.ts: On collision, a new package is created from [defaultChannelName]. Verify this produces correct docs navigation for the colliding channel.

…ple specs

Co-Authored-By: will.kendall@buildwithfern.com <wpk235@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 25 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions Bot added the Stale This PR hasn't has any commits or comments in 25 days or more. label Mar 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR was closed because it has been inactive for 5 days after being marked stale.

@github-actions github-actions Bot closed this Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Stale This PR hasn't has any commits or comments in 25 days or more.

Development

Successfully merging this pull request may close these issues.

0 participants