Skip to content

[2.0] Fixes #37701: Reserve the Admin role name and label the admin flag apart from roles (backport 2.0 #37702) - #38121

Merged
manerow merged 1 commit into
2.0from
fix/admin-role-name-collision-2.0
Nov 18, 2026
Merged

manerow merged 1 commit into
2.0from
fix/admin-role-name-collision-2.0

Conversation

@manerow

@manerow manerow commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Backport of #37702 to 2.0. Fixes #37701.

Admin access is the isAdmin flag on a user or bot, not a role, but the role editors list the flag as an option called "Admin". A custom role named Admin therefore showed up as a second, identical "Admin" option. The server now rejects a new role named Admin (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.0 has the older Ant Design role editors and none of the AI-mode screens. So this is a port, not a copy:

  • Same as Fixes 37701: Reserve the Admin role name and label the admin flag apart from roles #37702: the server check, the error message, the IT, the decision record, and the label.admin-superuser key with the same translation in every locale.
  • UI, ported to the 2.0 components: the bot and user role editors (RolesCard, UserProfileRoles), the read-only roles view (RolesElement), the user popover (UserRoles) and the profile menu (UserProfileIcon).
  • Left out: the AI-mode screens (BotDetailPanel, RolesRow, AIUserMenu), which do not exist on 2.0, and the "held role missing from the loaded list" fix, which was specific to the newer Autocomplete editor. The 2.0 editors use an Ant Design Select and never labelled such a role as the flag.

Type of change:

  • Bug fix

Tests:

Unit tests

  • New case in UserProfileRoles.test.tsx: the flag chip reads "Admin (superuser)" next to a custom role named Admin. It fails without the fix.
  • UserRoles.test.tsx updated to the new label.
  • Ran src/components/common/PopOverCard, RolesCard, RolesElement, Settings/Users and Settings/Bot on 2.0: 23 suites, 162 tests, all passed. ESLint, Prettier and tsc clean on changed files.

Backend integration tests

  • RoleResourceIT#test_roleNamedAdminIsRejected on 2.0: passed (MySQL + Elasticsearch, isolated and parallel lanes).

UI screen recording:

Not applicable: a bug fix that changes a label.

Checklist:

RetriggerView in GreptileConfidence Score: 4/5

The label gap is non-blocking, but the test must satisfy the repository's explicit testing requirement before merging.

Findings

  1. P2 Selected admins keep ambiguous labels ▶
  2. P2 Test skips the visible labels ▶

Summary

Reserves Admin as a new role name and labels the admin flag as “Admin (superuser)” across the existing UI.

  • New roles cannot use the name Admin.
  • Role views label the administrator flag as Admin (superuser).

Reviews (1) · Last reviewed commit: "Fixes 37701: Reserve the Admin role name..." · Reviewed by Greptile

@manerow
manerow requested review from a team as code owners November 18, 2026 13:05
@manerow manerow added UI UI specific issues backend skip-pr-checks Bypass PR metadata validation check labels Nov 18, 2026
@manerow
manerow requested review from karanh37 and mohityadav766 and removed request for a team November 18, 2026 13:05
- **Status:** Accepted
- **Revisions:** v1 2026-11-12 (initial)
- **Deciders:** Adrià Manero
- **Guard:** `RoleResourceIT.test_roleNamedAdminIsRejected`, `RolesCard.test.tsx`

@gitar-bot gitar-bot Bot Nov 18, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 👍 / 👎

@gitar-bot

gitar-bot Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findings

Rejecting 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 Admin server-side and relabeling the isAdmin flag as "Admin (superuser)" across the role UI. Approved with suggestions: the decision record names RolesCard.test.tsx as a guard, but that file does not exist on 2.0, so the RolesCard label change has no test. Either add that test or point the ADR's Guard line at UserProfileRoles.test.tsx.

💡 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 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`
🤖 Prompt for agents
Code Review: Backports the reserved Admin role name fix to 2.0, rejecting new roles named `Admin` server-side and relabeling the isAdmin flag as "Admin (superuser)" across the role UI. Approved with suggestions: the decision record names `RolesCard.test.tsx` as a guard, but that file does not exist on `2.0`, so the `RolesCard` label change has no test. Either add that test or point the ADR's Guard line at `UserProfileRoles.test.tsx`.

1. 💡 Quality: ADR lists RolesCard.test.tsx as a guard, but that file isn't on 2.0
   Files: 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 `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`).

   Fix (Point the guard at the test this backport adds.):
   - **Guard:** `RoleResourceIT.test_roleNamedAdminIsRejected`, `UserProfileRoles.test.tsx`

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

Comment on lines +62 to 63
label: t('label.admin-superuser'),
value: toLower(TERM_ADMIN),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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.

Comment on lines +216 to +227
expect(Chip).toHaveBeenCalledWith(
expect.objectContaining({
data: [
expect.objectContaining({
id: 'admin',
displayName: 'label.admin-superuser',
}),
adminRole,
],
}),
expect.anything()
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 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!

@manerow
manerow merged commit d3c1b12 into 2.0 Nov 18, 2026
72 of 79 checks passed
@manerow
manerow deleted the fix/admin-role-name-collision-2.0 branch November 18, 2026 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend skip-pr-checks Bypass PR metadata validation check UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant