OpenMetadata icon indicating copy to clipboard operation
OpenMetadata copied to clipboard

Add search support for Roles entity to enable scalable role selection

Open Rohit0301 opened this issue 7 months ago • 10 comments

Summary

The role selection dropdown across the UI, including user creation, bot configuration, and SSO role mapping, still relies on GET /v1/roles with cursor-based pagination. Because of that, roles beyond the first page can be omitted from the dropdown and cannot be reliably selected in the UI.

Backend support for searchable roles is already available, but the frontend role picker flows have not yet been updated to use it. As a result, the UI still depends on paginated list fetching, inflated limits, or page iteration, which does not scale well for larger role sets.

Current Behavior

  • Role selection dropdowns fetch roles using the paginated list API (GET /v1/roles).
  • Roles beyond the pagination boundary are not shown in the dropdown unless additional pages are fetched.
  • Users cannot reliably search or filter roles from the dropdown in larger deployments.
  • The frontend works around this by using large limits such as limit: 1000 or looping through pages, which is inefficient and still not ideal for UX.

UI Problem

This issue is visible anywhere the UI uses a role picker.

  • Dropdowns do not provide a scalable typeahead experience backed by the available role search support.
  • Users must scroll through a partial or incomplete list of roles.
  • If the required role is outside the fetched page range, it appears unavailable in the UI.
  • The experience becomes increasingly unreliable as the number of roles grows.

In practice, the backend can support the use case, but the frontend is not yet wired to use that capability.

Expected Behavior

Users should be able to find and select any role regardless of how many roles exist.

The UI should:

  • use the existing backend role search support
  • provide a searchable/typeahead role dropdown
  • fetch matching roles dynamically instead of depending on paginated full-list loading
  • allow users to reliably select roles even when they are not part of the initially loaded page

Proposed UI Changes

Update role picker components across the UI to use the existing searchable backend support instead of relying on paginated role listing.

Expected UI behavior:

  • the role dropdown should allow users to type and search by role name
  • matching roles should be fetched dynamically from the backend search-capable endpoint
  • the dropdown should show loading, empty, and no-match states appropriately
  • role selection should work consistently across all role assignment surfaces

This applies to flows such as:

  • user creation and edit
  • bot configuration
  • SSO role mapping
  • any other UI surface that depends on selecting roles

Impact

  • Users with 100+ roles cannot reliably assign roles during user creation or configuration.
  • Role assignment flows are misleading because missing roles appear unavailable in the dropdown.
  • Playwright coverage is impacted as well:
    • UserCreationWithPersona.spec.ts fails when the target role falls beyond the pagination boundary.

Notes

This is no longer a backend capability gap. The remaining work is to adopt the existing backend role search support in the frontend role selector components and replace the current paginated list-based behavior.

Rohit0301 avatar Apr 20 '26 06:04 Rohit0301

That's sounds interesting, can I work on this

ShivamChavan01 avatar Apr 20 '26 07:04 ShivamChavan01

@ShivamChavan01 assigned to you

chirag-madlani avatar Apr 20 '26 09:04 chirag-madlani

hi @chirag-madlani may i please work on this issue?

mohitjeswani01 avatar Apr 20 '26 12:04 mohitjeswani01

Hi, I’d like to work on this issue. Could you please assign it to me?

vedant45 avatar Apr 20 '26 13:04 vedant45

Hi @chirag-madlani! I'd love to work on this issue. I've analyzed the codebase and have a clear implementation plan: Root Cause: Roles lack a dedicated search index (RoleIndex class) unlike User and Team which have user_search_index and team_search_index respectively.

My Plan:

1.Create a RoleIndex class in the search indexing layer 2.Add SearchIndex.ROLE mapping on the frontend 3.Wire up the existing /v1/search/query endpoint to support roles 4.Replace paginated list calls in role selection dropdowns with search/typeahead backed calls 5.Fix the failing UserCreationWithPersona.spec.ts Playwright test

I've already forked the repo and am ready to start immediately. This will be a complete end-to-end fix covering backend index mapping, frontend SearchIndex enum, and the dropdown components. Can you assign this to me? 🙏

SahilAhuja007 avatar Apr 20 '26 17:04 SahilAhuja007

Hi all.I'm already assigned to this issue. Working on it and will have a PR up soon. 🙏

ShivamChavan01 avatar Apr 20 '26 18:04 ShivamChavan01

Hi @chirag-madlani — I’ve completed the full implementation for this issue and also resolved the GitTar bot issues on the PR.

All validation tests are passing successfully, and the PR is now ready for review.

Could you please apply the safe to test label on my PR so the checks can proceed?

PR: https://github.com/open-metadata/OpenMetadata/pull/27556

Thank you! 🙏

SahilAhuja007 avatar Apr 20 '26 21:04 SahilAhuja007

@ShivamChavan01 FYI,The backend implementation is already done, you just need to work on the frontend integration for role search api. Backend PR is already merged - https://github.com/open-metadata/OpenMetadata/pull/27335

Rohit0301 avatar Apr 21 '26 05:04 Rohit0301

@ShivamChavan01 FYI,The backend implementation is already done, you just need to work on the frontend integration for role search api. Backend PR is already merged - https://github.com/open-metadata/OpenMetadata/pull/27335

Okay I'll do it ill raise a pr in like few hr

ShivamChavan01 avatar Apr 21 '26 05:04 ShivamChavan01

Hey @Rohit0301, The implementation is complete and ready for review! Changes made:

  1. Added searchRoles() function in rolesAPIV1.ts using Elasticsearch
  2. Replaced getAllRoles/getRoles with searchRoles in 5 components:
    • CreateUserPage.component.tsx
    • BotDetails.component.tsx
    • LdapRoleMappingWidget.tsx
    • SsoRolesSelectField.tsx
    • UserProfileRoles.component.tsx
  3. Added onSearch handlers for server-side typeahead filtering
  4. Fixed error handling with try/catch
  5. Added ES character sanitization
  6. Fixed shared state issue with per-mapping searchResults Map All 3 review comments addressed. PR #27602 ready for re-review

ShivamChavan01 avatar Apr 21 '26 16:04 ShivamChavan01