Repository navigation
[2.0] Fixes #37701: Reserve the Admin role name and label the admin flag apart from roles (backport 2.0 #37702) - #38121
Conversation
| - **Status:** Accepted | ||
| - **Revisions:** v1 2026-11-12 (initial) | ||
| - **Deciders:** Adrià Manero | ||
| - **Guard:** `RoleResourceIT.test_roleNamedAdminIsRejected`, `RolesCard.test.tsx` |
There was a problem hiding this comment.
💡 Quality: ADR lists RolesCard.test.tsx as a guard, but that file isn't on 2.0
The decision record names RolesCard.test.tsx as one of the guards for this decision. On the 2.0 branch, components/common/RolesCard/ has only RolesCard.component.tsx and RolesCard.interfaces.ts. No such test exists, and this PR doesn't add one. As a result, the RolesCard label change (line 79) has no test, and the ADR points readers to a guard that isn't there. Either add a RolesCard.test.tsx that checks the label.admin-superuser option, or change the Guard line to name the test this backport actually adds (UserProfileRoles.test.tsx).
Point the guard at the test this backport adds.:
- **Guard:** `RoleResourceIT.test_roleNamedAdminIsRejected`, `UserProfileRoles.test.tsx`
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findingsRejecting new roles named Admin may require administrators to choose another name; the UI label clarifies the separate superuser flag. Backports the reserved Admin role name fix to 2.0, rejecting new roles named 💡 Quality: ADR lists RolesCard.test.tsx as a guard, but that file isn't on 2.0📄 docs/decisions/2026-11-12-admin-is-a-reserved-role-name.md:6 📄 openmetadata-ui/src/main/resources/ui/src/components/common/RolesCard/RolesCard.component.tsx:79 The decision record names Point the guard at the test this backport adds.🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
| label: t('label.admin-superuser'), | ||
| value: toLower(TERM_ADMIN), |
There was a problem hiding this comment.
Selected admins keep ambiguous labels. When editing an existing admin,
selectedRoles includes 'admin', but !isUserAdmin excludes its option. The new label is therefore unavailable, and Select shows the raw value instead of “Admin (superuser)”. A held role named Admin remains hard to distinguish from the flag.
Keep the translated option available for selected admins too. The same gap exists in RolesCard.
| expect(Chip).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| data: [ | ||
| expect.objectContaining({ | ||
| id: 'admin', | ||
| displayName: 'label.admin-superuser', | ||
| }), | ||
| adminRole, | ||
| ], | ||
| }), | ||
| expect.anything() | ||
| ); |
There was a problem hiding this comment.
Test skips the visible labels. The new test checks arguments passed to a mocked
Chip, while getEntityName is also mocked. It can pass even if the real page renders identical labels. The repository requires “Test real behavior, not mock wiring” and “Test the outcome, not the implementation.” Render the real label components and assert that both distinct labels appear.
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Describe your changes:
Backport of #37702 to
2.0. Fixes #37701.Admin access is the
isAdminflag on a user or bot, not a role, but the role editors list the flag as an option called "Admin". A custom role namedAdmintherefore showed up as a second, identical "Admin" option. The server now rejects a new role namedAdmin(any case) with a 400; existing roles with that name keep working. In the UI, the flag reads "Admin (superuser)" wherever it is listed among roles.The cherry-pick did not apply:
2.0has the older Ant Design role editors and none of the AI-mode screens. So this is a port, not a copy:label.admin-superuserkey with the same translation in every locale.2.0components: the bot and user role editors (RolesCard,UserProfileRoles), the read-only roles view (RolesElement), the user popover (UserRoles) and the profile menu (UserProfileIcon).BotDetailPanel,RolesRow,AIUserMenu), which do not exist on2.0, and the "held role missing from the loaded list" fix, which was specific to the newerAutocompleteeditor. The2.0editors use an Ant DesignSelectand never labelled such a role as the flag.Type of change:
Tests:
Unit tests
UserProfileRoles.test.tsx: the flag chip reads "Admin (superuser)" next to a custom role namedAdmin. It fails without the fix.UserRoles.test.tsxupdated to the new label.src/components/common/PopOverCard,RolesCard,RolesElement,Settings/UsersandSettings/Boton2.0: 23 suites, 162 tests, all passed. ESLint, Prettier andtscclean on changed files.Backend integration tests
RoleResourceIT#test_roleNamedAdminIsRejectedon2.0: passed (MySQL + Elasticsearch, isolated and parallel lanes).UI screen recording:
Not applicable: a bug fix that changes a label.
Checklist:
Fixes #<issue-number>above.REVIEW.md; no findings.The label gap is non-blocking, but the test must satisfy the repository's explicit testing requirement before merging.
Findings
Summary
Reserves
Adminas a new role name and labels the admin flag as “Admin (superuser)” across the existing UI.Reviews (1) · Last reviewed commit: "Fixes 37701: Reserve the Admin role name..." · Reviewed by Greptile