Skip to content

Fixes #38296: prevent duplicate list fetches on pagination - #38308

Merged
sweta1308 merged 15 commits into
open-metadata:mainfrom
Kefia-02:fix/38296-single-fetch-pagination-20261120
Nov 23, 2026
Merged

sweta1308 merged 15 commits into
open-metadata:mainfrom
Kefia-02:fix/38296-single-fetch-pagination-20261120

Conversation

@Kefia-02

@Kefia-02 Kefia-02 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Eleven cursor-paginated lists issue the same page request twice. Their page-change handler invokes a fetch and then changes the URL paging cursor; the URL-driven pagingCursor effect issues an identical second fetch.

Affected: Roles, Policies, Bots, Notification alerts, Classification tags, Service version, Services, Team users, Applications, Marketplace, Database schema version.

Change

  • Make the page-change handlers update the paging cursor only.
  • Keep a single fetching path in the existing pagingCursor effects, which already handle first load, restored URLs, page-size changes and reloading.
  • Search-mode paging in Services and Team users also goes through the effect. currentPage is part of pagingCursor, so the old handler fetch raced a second effect request: Services re-searched page 1, Team users reloaded the unfiltered team list. The effect now passes the URL page number to the search.
  • Services resets page and cursor when the service-type filter value changes (not on sort) or Show deleted is toggled, as the search handler already did, so a filter change no longer opens on the previous page number.
  • React Router applies URL paging resets in a transition, so a filter or search change can fetch once with the old page or cursor before the reset lands. Services, Team users and Bots now track the latest list request and ignore results, errors and loading state from superseded ones.
  • Preserve separate refreshes after deletion and classification changes.
  • Bots: the removed handler fetch passed showDeleted = false, so in deleted mode it raced the effect's deleted-bots request; only the effect's request remains.

Fixes #38296.

Verification

  • New regression test BotListV1 › fetches the next page exactly once when Next is clicked (real router, real Next button): passes on this branch, fails against the pre-fix component with two identical after requests.
  • New regression tests Services search paging › fetches the next search page once, at the requested page number and UserTab › Search paging › fetches the next search page once and does not reload the unfiltered team list: pass on this branch, fail against the previous handlers (Services searched with currentPage: undefined; Team users called getUsers).
  • New regression test Services search paging › returns to page 1 when the deleted filter changes on a later search page: passes on this branch, fails without the reset.
  • New regression tests Services overlapping list requests › keeps the newest deleted list when the stale-cursor request resolves last and UserTab › Search paging › keeps the newest search results when an older search resolves last: pass on this branch, fail without the request guard.
  • New regression test BotListV1 › keeps the newest deleted bots when the stale-cursor request resolves last: passes on this branch, fails without the guard in fetchBots.
  • New regression test ClassificationDetails.paging.test.tsx › fetches the next page after switching classification on page 1: passes on this branch, fails with the skip flag forced to true (Number of calls: 0).
  • ClassificationDetails: the page-1 check moved out of the tag-loading effect to keep it under the ESLint complexity limit (ui-checkstyle).
  • Component suites for all eleven pages pass locally (ClassificationDetails, BotListV1, NotificationListPage, PoliciesListPage, RolesListPage, ServiceVersionPage, Services, Services.paging, UserTab, ApplicationPage, DatabaseSchemaVersionPage).
  • Earlier runs on 5ff7b76f: focused verification, dependency-based run.
  • Browser-mode single-request tests marked duplicateFetchOnPageChange in the unmerged Fixes #37219: Vitest browser-mode UI integration tests (Pagination migration, marked) + CI #35623 should have their knownIssues markers removed once it lands.

Prepared with AI assistance.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; no new actionable issues were found.

Summary

The PR removes duplicate page requests from eleven lists by letting URL-driven effects fetch each page.

  • Page changes load each list through one request.
  • Search lists load the selected page and reset paging when needed.
  • Only the newest list request can update results and loading state.
  • Classification tag paging keeps working after switching classifications.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[User clicks Next or Previous] --> B[Handler updates URL paging]
  B --> C[Paging effect fetches requested page]
  C --> D[Page displays results]
Loading

Reviews (17) · Last reviewed commit: "test(ui): cover the first Next after swi..." · Reviewed by Greptile

@Kefia-02
Kefia-02 requested a review from a team as a code owner November 20, 2026 12:56
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@greptile-apps

This comment has been minimized.

Kefia-02 added a commit to Kefia-02/OpenMetadata that referenced this pull request Nov 22, 2026
Services, Team users, Applications, Marketplace and Database schema version
fetched the page in their Next/Previous handler and again in the pagingCursor
effect. Keep the effect as the single fetch path, and add a Bots regression
test asserting one request per page change.
…ationDetails effect complexity

Services and Team users still fetched in their search-mode page handler while
the pagingCursor effect also fired (currentPage is part of the cursor): Services
re-searched page 1, Team users reloaded the unfiltered team list. Make the
effect the single fetch path for search paging too, and add regression tests.

Move the page-1 check out of the ClassificationDetails effect so it is back
under the ESLint complexity limit that failed ui-checkstyle.
sweta1308 and others added 3 commits November 23, 2026 12:59
…r changes

The search effect now pages by the URL page number, so a filter change that kept
the previous page searched that page of the new filter and could land on an
empty page. Reset page and cursor when the service-type filter value changes
(not on sort) and when Show deleted is toggled, matching the search handler.
A service-type filter change can commit its local page reset before the URL cursor catches up. Skip that transient mismatch so the old page is never searched and cannot race the replacement page-1 response.

Keep the existing cursor effect as the single fetch path and preserve all preceding maintainer changes. Add a real-router regression that starts on page 2 with a cursor, selects Airbyte in the actual type filter, checks that only page 1 is requested, and verifies the matching service remains visible and the old cursor is cleared.

The regression fails at dc695ed (page 2) and at 513a3c1 (requests for pages 2 and 1). With this fix, 70 tests across Services, Services paging, UserTab and ClassificationDetails pass locally. All 14 PR source files pass organize-imports, ESLint, Prettier and license-header checks. Node 22.23.5; no paid runner or service used.
…and Bots

React Router applies URL paging resets in a transition, so a filter or search
change can render (and fetch) once with the old page or cursor before the reset
lands. Both requests then race and the older response could win. Track the
latest request in each list fetch and ignore results, errors and loading state
from superseded ones. Regression tests resolve the stale request last.
Kefia-02 and others added 2 commits November 23, 2026 18:03
Wait for the URL paging cursor to match the local currentPage before fetching team users. Search using that synchronized page while keeping the latest-request response guard.

Add real-router regressions for starting a search from page 2 and clearing a search on page 2. Before the fix these issue search pages [2, 1] and two unfiltered requests; after the fix each sends one request for page 1. Exercise stale-response protection with two distinct searches instead of depending on an unwanted stale-page request.

Validation: all 17 UserTab tests pass, with no failures or skips. Both new regressions fail against parent 5504a77. Organize imports, ESLint and Prettier pass for the two changed files.

Addresses the UserTab finding in PR open-metadata#38308 review 6018797346.
Toggle Show deleted from page 1 with a before cursor so the stale-cursor
request resolves last, and assert the newer deleted list stays rendered.
Fails without the guard in fetchBots.
@sweta1308 sweta1308 added To release Will cherry-pick this PR into the release branch UI UI specific issues safe to test Add this label to run secure Github workflows on PRs labels Nov 23, 2026

@ShaileshParmar11 ShaileshParmar11 left a comment

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.

UI review at 76a5e25. The fix looks right, and I'd merge it once the ClassificationDetails change has a regression test (inline).

What I checked:

  • Every one of the nine pages whose handler fetch was deleted already has a pagingCursor effect that fetches, so no page is left without a fetch path.
  • usePaging memoizes pagingCursor on primitive values, so a reset to the same page does not re-run effects. That is what makes the isPagedPastFirstPage change necessary.
  • The page-mismatch skip in the Services and UserTab effects means a search or filter reset from a later page sends one request, not two.
  • Both earlier bot findings (first Next lost after switching classification; UserTab double search) are fixed on this head.
  • Locally on this head, BotListV1.component.test.tsx, Services.paging.test.tsx, UserTab.test.tsx and ClassificationDetails.test.tsx all pass (55 tests).

The playwright job was skipped on this PR.

Switching classification on page 1 leaves the URL unchanged, so the skip flag
must not be set or the next Next click sends no request. Exercise it with real
navigation and a Next button in the TableV2 mock, in its own file because the
existing suite stubs useNavigate. Fails with the flag forced to true.
@gitar-bot

gitar-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk 2 closed / 2 findings

Routing pagination and search requests through URL-driven effects across eleven lists could change which page data users see after filter or search updates.

Removes duplicate list fetches on pagination across eleven cursor-paginated pages by keeping a single fetch path in the URL paging cursor effects, and ignores superseded responses in Services, Team users and Bots. Resolved the lost first Next click after switching classification in Classification tags and the duplicate search requests from a later page in UserTab search. No open issues found.

✅ 2 closed
✅ Bug: Classification tags: first Next click after switching classification is lost

📄 openmetadata-ui/src/main/resources/ui/src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:253-260 📄 openmetadata-ui/src/main/resources/ui/src/components/Classifications/ClassificationDetails/ClassificationDetails.tsx:542-556
The URL effect sets isClassificationChangingRef = true when the classification changes and calls handlePageChange(1, {cursorType: null}). It expects that call to change pagingCursor and re-run the effect, which clears the flag. That only happens if you were past page 1. When you start on page 1, pagingCursor is already {cursorType: undefined, cursorValue: undefined, currentPage: '1'}, because usePaging treats a missing currentPage as 1. Its memo stays the same, so the effect doesn't re-run and the flag stays true.

Before this PR, handlePaging fetched the page directly, which hid the stuck flag. Now the URL effect is the only path that fetches. So the next Next/Previous click on the new classification changes the URL and page number, but the effect only clears the flag and returns. No request goes out, and the table keeps showing page 1's tags under a page-2 indicator.

Fix: only set the flag when the reset will actually change the cursor (or clear it at the end of the change branch). Another option is to drop the ref and dedupe by comparing the cursor that was last fetched.

✅ Performance: UserTab search from a later page still fires two list requests

📄 openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/UserTab/UserTab.component.tsx:253-267
handleUsersSearchAction updates searchText right away, but the URL reset from handlePageChange(1, …) arrives later in a router transition. The effect therefore runs once with the new searchText and the old pagingCursor, which sends searchUsers(text, 2) (or getCurrentTeamUsers with the stale cursor when the search is cleared). It then runs again for page 1 once the URL catches up. The new latest-request guard throws away the stale result, and the added test 'keeps the newest search results when an older page resolves last' relies on that, but the duplicate request this PR aims to remove (#38296) is still sent. Services handles the same case by skipping the effect while local paging and the URL disagree; UserTab could do the same.

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

@ShaileshParmar11 ShaileshParmar11 left a comment

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.

Approving at 26a4520. The new ClassificationDetails.paging.test.tsx passes on this head and fails with isClassificationChangingRef.current = true; (Number of calls: 0), so it guards the fix. The BotListV1, Services.paging, UserTab and ClassificationDetails suites also pass locally (56 tests in all).

Optional cleanup, not blocking: the new file copies almost all of the mocks from ClassificationDetails.test.tsx, but this test only needs four (useEntityRules, rest/tagAPI, rest/miscAPI and TableV2). With only those, it still passes and still fails without the fix, and the file drops from 365 to 166 lines.

@sweta1308
sweta1308 merged commit 55b747a into open-metadata:main Nov 23, 2026
51 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.0 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Backport to 2.1 is under way. It is built from openmetadata-collate, which holds the credentials needed to open a PR here, and it will comment again with the result — nothing is needed from you unless it reports otherwise.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.1 opened as #38472 (clean cherry-pick). It merges itself once the checks pass.

@gh-bot-collate

Copy link
Copy Markdown

🤖 Backport to 2.0 failed. The conflict could not be resolved, so this change is not on that branch. Resolver run.

sweta1308 added a commit that referenced this pull request Nov 23, 2026
…38472)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(ui): fetch paginated lists only in URL cursor effects (#38296)

* fix(classification): do not suppress first pagination fetch after page-1 switch

* fix(ui): drop duplicate page fetch from remaining cursor paging handlers

Services, Team users, Applications, Marketplace and Database schema version
fetched the page in their Next/Previous handler and again in the pagingCursor
effect. Keep the effect as the single fetch path, and add a Bots regression
test asserting one request per page change.

* fix(ui): page search results through the cursor effect; cap ClassificationDetails effect complexity

Services and Team users still fetched in their search-mode page handler while
the pagingCursor effect also fired (currentPage is part of the cursor): Services
re-searched page 1, Team users reloaded the unfiltered team list. Make the
effect the single fetch path for search paging too, and add regression tests.

Move the page-1 check out of the ClassificationDetails effect so it is back
under the ESLint complexity limit that failed ui-checkstyle.

* fix(ui): reset Services paging when the service-type or deleted filter changes

The search effect now pages by the URL page number, so a filter change that kept
the previous page searched that page of the new filter and could land on an
empty page. Reset page and cursor when the service-type filter value changes
(not on sort) and when Show deleted is toggled, matching the search handler.

* fix(ui): wait for the reset cursor before fetching filtered services

A service-type filter change can commit its local page reset before the URL cursor catches up. Skip that transient mismatch so the old page is never searched and cannot race the replacement page-1 response.

Keep the existing cursor effect as the single fetch path and preserve all preceding maintainer changes. Add a real-router regression that starts on page 2 with a cursor, selects Airbyte in the actual type filter, checks that only page 1 is requested, and verifies the matching service remains visible and the old cursor is cleared.

The regression fails at dc695ed (page 2) and at 513a3c1 (requests for pages 2 and 1). With this fix, 70 tests across Services, Services paging, UserTab and ClassificationDetails pass locally. All 14 PR source files pass organize-imports, ESLint, Prettier and license-header checks. Node 22.23.5; no paid runner or service used.

* fix(ui): apply only the newest list response in Services, Team users and Bots

React Router applies URL paging resets in a transition, so a filter or search
change can render (and fetch) once with the old page or cursor before the reset
lands. Both requests then race and the older response could win. Track the
latest request in each list fetch and ignore results, errors and loading state
from superseded ones. Regression tests resolve the stale request last.

* fix(ui): avoid duplicate team requests during search page resets

Wait for the URL paging cursor to match the local currentPage before fetching team users. Search using that synchronized page while keeping the latest-request response guard.

Add real-router regressions for starting a search from page 2 and clearing a search on page 2. Before the fix these issue search pages [2, 1] and two unfiltered requests; after the fix each sends one request for page 1. Exercise stale-response protection with two distinct searches instead of depending on an unwanted stale-page request.

Validation: all 17 UserTab tests pass, with no failures or skips. Both new regressions fail against parent 5504a77. Organize imports, ESLint and Prettier pass for the two changed files.

Addresses the UserTab finding in PR #38308 review 6018797346.

* test(ui): cover the Bots latest-request guard on a deleted toggle

Toggle Show deleted from page 1 with a before cursor so the stale-cursor
request resolves last, and assert the newer deleted list stays rendered.
Fails without the guard in fetchBots.

* test(ui): cover the first Next after switching classification on page 1

Switching classification on page 1 leaves the URL unchanged, so the skip flag
must not be set or the next Next click sends no request. Exercise it with real
navigation and a Next button in the TableV2 mock, in its own file because the
existing suite stubs useNavigate. Fails with the flag forced to true.

---------


(cherry picked from commit 55b747a)

Co-authored-by: Kefia-02 <[email protected]>
Co-authored-by: Sweta Agarwalla <[email protected]>
sweta1308 pushed a commit that referenced this pull request Nov 23, 2026
)

Manually adapt main merge 55b747a to the 2.0 Ant Design views and retain inherited team-user search/export behavior.

Keep URL-driven effects as the single fetch path in eleven cursor-paginated lists; preserve search/filter resets and latest-response guards. Add 2.0 regressions with the real table/pager for classification and the real marketplace pager, and account for the separate bot-map load.

Validation: 13 relevant suites / 105 unique tests pass using the normal 2.0 Jest configuration. Six selected regressions fail on unchanged base 8e6938f. Restoring the old page-1 classification skip also fails its regression. Core components build, schema/ANTLR generation, all 16 changed-file UI checkstyle checks, and git diff --check pass.
chirag-madlani added a commit that referenced this pull request Nov 25, 2026
… tests (#38651)

#38309 and #38308 fixed the Data Models / Stored Procedures page reset and the duplicate fetch on page change, so the browser tests no longer need the knownIssues escape hatch: the single-fetch assertion in paginationContract is now unconditional, the option is removed, the four Playwright tests for those tabs are tagged @migrated-browser again, and PAGINATION_MIGRATION.md reflects 35 tagged / 4 untagged.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs To release Will cherry-pick this PR into the release branch UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Six list pages fetch twice on every page change

3 participants