-
Notifications
You must be signed in to change notification settings - Fork 47.2k
chore(core): Ensure unique display name for roles #20601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
afitzek
wants to merge
2
commits into
master
Choose a base branch
from
pay-3948-make-role-name-unique
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6b963bd
to
37b3e55
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
1200fab
to
6fdc7fc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 issues found across 15 files
Prompt for AI agents (all 5 issues)
Understand the root cause of the following 5 issues and fix them.
<file name="packages/cli/test/integration/shared/db/roles.ts">
<violation number="1" location="packages/cli/test/integration/shared/db/roles.ts:167">
The cleanup helper now propagates delete failures for system or referenced roles, so tests depending on cleanupRolesAndScopes() will start failing once a role can’t be removed.</violation>
<violation number="2" location="packages/cli/test/integration/shared/db/roles.ts:177">
Removing the try/catch around scope deletion causes cleanupRolesAndScopes() to throw whenever a test scope is still referenced, breaking the cleanup helper used by integration tests.</violation>
</file>
<file name="packages/@n8n/backend-test-utils/src/migration-test-helpers.ts">
<violation number="1" location="packages/@n8n/backend-test-utils/src/migration-test-helpers.ts:99">
Respect migrations that disable transactions when undoing the last migration by falling back to transaction: 'none' instead of hard-coding 'each'.</violation>
</file>
<file name="packages/@n8n/db/src/migrations/common/1760020838000-UniqueRoleNames.ts">
<violation number="1" location="packages/@n8n/db/src/migrations/common/1760020838000-UniqueRoleNames.ts:30">
Renaming duplicates with a fixed “ +<n>” suffix only guarantees uniqueness within that duplicate set. If another role already uses the same suffixed display name, this update will create a fresh conflict and the unique index creation will fail. Please ensure the generated name is unique across the entire table (e.g., track used display names and keep incrementing until a free value is found).</violation>
</file>
<file name="packages/cli/src/services/role.service.ts">
<violation number="1" location="packages/cli/src/services/role.service.ts:177">
Rule violated: **Prefer Typeguards over Type casting**
Please replace the new `error as Error` cast with a proper type guard to comply with the "Prefer Typeguards over Type casting" rule.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai
to give feedback, ask questions, or re-run the review.
packages/@n8n/db/src/migrations/common/1760020838000-UniqueRoleNames.ts
Outdated
Show resolved
Hide resolved
8060761
to
a7d7d58
Compare
a7d7d58
to
6020bdd
Compare
6020bdd
to
8d574de
Compare
8d574de
to
f0a6de0
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Display names for roles should be unique to help avoid confusion for customers. This adds a unique constraint into the database to ensure this and a migration path to fix current duplicates. The migration was inspired by
1620821879465-UniqueWorkflowNames
.Related Linear tickets, Github issues, and Community forum posts
closes https://linear.app/n8n/issue/PAY-3948/make-role-name-unique
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)