Skip to content

fix: report component renaming conflicts for same-name components from different files - #2706

Merged
kanoru3101 merged 14 commits into
mainfrom
fix/component-renaming-conflicts-severity-ignored-the-reference
Apr 14, 2026
Merged

fix: report component renaming conflicts for same-name components from different files#2706
kanoru3101 merged 14 commits into
mainfrom
fix/component-renaming-conflicts-severity-ignored-the-reference

Conversation

@kanoru3101

@kanoru3101 kanoru3101 commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

What/Why/How?

The bundle command now reports component renaming conflicts whenever two external definitions share the same name but have different content.

Also, another issue was that we created two types of uniq names. For pointer - it was with prefix, and for other cases was suffix

Removed logic to create prefix for the component name when the component name has the same name

Tested with other products

Reference

close #2691

Testing

Without --component-renaming-conflicts-severity rule

Screenshot 2026-04-06 at 19 53 19

With --component-renaming-conflicts-severity=error rule

Screenshot 2026-04-06 at 19 53 49

With --component-renaming-conflicts-severity=warn rule

Screenshot 2026-04-06 at 19 54 21

With --component-renaming-conflicts-severity=off rule

Screenshot 2026-04-06 at 19 54 51

Screenshots (optional)

Check yourself

  • Code changed? - Tested with Redoc/Realm/Reunite (internal)
  • All new/updated code is covered by tests
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update considered

Security

  • The security impact of the change has been considered
  • Code follows company security practices and guidelines

Note

Medium Risk
Changes bundling component naming and conflict detection, which can alter generated component names and $ref paths in bundled outputs. Risk is moderate due to potential breaking snapshot/output diffs for consumers relying on stable bundled names.

Overview
Bundling now detects and reports component renaming conflicts when external components share the same name but have different content, honoring --component-renaming-conflicts-severity for these cases.

Component name generation was simplified to derive names from the JSON pointer basename (falling back to the file basename) and then apply a consistent -2, -3, … suffix for conflicts; this changes some autogen component keys and resulting $ref targets.

Tests and fixtures were updated/added to cover pointer-based external refs conflicts and ensure dotted schema keys (e.g. my.org.User) are preserved, and snapshots were updated to reflect the new naming/warning behavior.

Reviewed by Cursor Bugbot for commit cf50a5b. Bugbot is set up for automated code reviews on this repo. Configure here.

@kanoru3101 kanoru3101 self-assigned this Mar 31, 2026
@changeset-bot

changeset-bot Bot commented Mar 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cf50a5b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch
@redocly/respect-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 79.96% (🎯 79%) 6723 / 8407
🔵 Statements 79.4% (🎯 79%) 6961 / 8767
🔵 Functions 83.09% (🎯 82%) 1366 / 1644
🔵 Branches 71.59% (🎯 71%) 4561 / 6371
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/bundle/bundle-visitor.ts 66.37% 61.98% 100% 66.37% 29, 33-41, 48-56, 63, 72, 80, 85-106, 171-183, 200-201, 214-215, 252
Generated in workflow #9426 for commit cf50a5b by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Mar 31, 2026

Copy link
Copy Markdown
Contributor
CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 3.440s ± 0.040s ▓ 1.02x
cli-next 3.386s ± 0.041s ▓ 1.00x (Fastest)

@kanoru3101 kanoru3101 added the snapshot Create experimental release PR label Mar 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1774945843 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1774945843
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1774945843
# or
npm install @redocly/respect-core@0.0.0-snapshot.1774945843

⚠️ Note: This is a development build and may contain unstable features.

Comment thread packages/core/src/bundle/bundle-visitor.ts Outdated
@kanoru3101
kanoru3101 marked this pull request as ready for review March 31, 2026 09:49
@kanoru3101
kanoru3101 requested review from a team as code owners March 31, 2026 09:49
Comment thread .changeset/quiet-snakes-buy.md Outdated

@tatomyr tatomyr left a comment

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.

The issue here is that the bundler doesn't apply renaming consistently. If the schema wasn't referenced with a JSON pointer inside the file, it would behave correctly.

Comment thread packages/core/src/__tests__/bundle.test.ts Outdated
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 3, 2026
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775209981 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775209981
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775209981
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775209981

⚠️ Note: This is a development build and may contain unstable features.

Comment thread packages/core/src/bundle/bundle-visitor.ts Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Hardcoded "schemas" in message for all component types
    • Updated the conflict report text to use the actual componentType and adjusted tests to assert the correct type-specific wording.

Create PR

Or push these changes by commenting:

@cursor push c4dddad26a
Preview (c4dddad26a)
diff --git a/packages/core/src/__tests__/bundle-oas.test.ts b/packages/core/src/__tests__/bundle-oas.test.ts
--- a/packages/core/src/__tests__/bundle-oas.test.ts
+++ b/packages/core/src/__tests__/bundle-oas.test.ts
@@ -50,7 +50,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('warn');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed first to first-2.`
+      `Two examples are referenced with the same name but different content. Renamed first to first-2.`
     );
     expect(res.parsed).toMatchSnapshot();
   });
@@ -62,7 +62,7 @@
     });
     expect(problems).toHaveLength(1);
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed param-b to param-b-2.`
+      `Two parameters are referenced with the same name but different content. Renamed param-b to param-b-2.`
     );
     expect(res.parsed).toMatchSnapshot();
   });

diff --git a/packages/core/src/__tests__/bundle.test.ts b/packages/core/src/__tests__/bundle.test.ts
--- a/packages/core/src/__tests__/bundle.test.ts
+++ b/packages/core/src/__tests__/bundle.test.ts
@@ -67,7 +67,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('warn');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed first to first-2.`
+      `Two examples are referenced with the same name but different content. Renamed first to first-2.`
     );
     expect(res.parsed).toMatchSnapshot();
   });
@@ -96,7 +96,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('warn');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed param-b to param-b-2.`
+      `Two parameters are referenced with the same name but different content. Renamed param-b to param-b-2.`
     );
     expect(res.parsed).toMatchSnapshot();
   });
@@ -119,7 +119,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('error');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed param-b to param-b-2.`
+      `Two parameters are referenced with the same name but different content. Renamed param-b to param-b-2.`
     );
   });
 
@@ -134,7 +134,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('warn');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed User to User-2.`
+      `Two parameters are referenced with the same name but different content. Renamed User to User-2.`
     );
     expect(res.parsed).toMatchSnapshot();
   });
@@ -163,7 +163,7 @@
     expect(problems).toHaveLength(1);
     expect(problems[0].severity).toBe('error');
     expect(problems[0].message).toEqual(
-      `Two schemas are referenced with the same name but different content. Renamed User to User-2.`
+      `Two parameters are referenced with the same name but different content. Renamed User to User-2.`
     );
   });
 

diff --git a/packages/core/src/bundle/bundle-visitor.ts b/packages/core/src/bundle/bundle-visitor.ts
--- a/packages/core/src/bundle/bundle-visitor.ts
+++ b/packages/core/src/bundle/bundle-visitor.ts
@@ -287,7 +287,7 @@
 
     if (!componentsGroup[name] && prevName !== name) {
       ctx.report({
-        message: `Two schemas are referenced with the same name but different content. Renamed ${prevName} to ${name}.`,
+        message: `Two ${componentType} are referenced with the same name but different content. Renamed ${prevName} to ${name}.`,
         location: ctx.location,
         forceSeverity: componentRenamingConflicts,
       });

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread packages/core/src/bundle/bundle-visitor.ts
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 6, 2026
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775468574 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775468574
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775468574
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775468574

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 6, 2026
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775489865 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775489865
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775489865
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775489865

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 6, 2026
@github-actions

github-actions Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775493945 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775493945
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775493945
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775493945

⚠️ Note: This is a development build and may contain unstable features.

Comment thread packages/core/src/bundle/bundle-visitor.ts
Comment thread packages/core/src/ref-utils.ts Outdated
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 7, 2026
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775558887 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775558887
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775558887
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775558887

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776152411 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776152411
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776152411
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776152411

⚠️ Note: This is a development build and may contain unstable features.

Comment thread .changeset/quiet-snakes-buy.md Outdated
Co-authored-by: Andrew Tatomyr <andrew.tatomyr@redocly.com>
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776165174 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776165174
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776165174
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776165174

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101
kanoru3101 merged commit 39205c3 into main Apr 14, 2026
54 checks passed
@kanoru3101
kanoru3101 deleted the fix/component-renaming-conflicts-severity-ignored-the-reference branch April 14, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot Create experimental release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bundle with --component-renaming-conflicts-severity ignored the reference

3 participants