Skip to content

Fixes 38927: Show the selected Incident Manager page after paging - #38945

Merged
ShaileshParmar11 merged 2 commits into
mainfrom
ShaileshParmar11/incident-list-pagination-race
Nov 27, 2026
Merged

ShaileshParmar11 merged 2 commits into
mainfrom
ShaileshParmar11/incident-list-pagination-race

Conversation

@ShaileshParmar11

@ShaileshParmar11 ShaileshParmar11 commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #38927

With more than one page of incidents, opening a later page in the Incident Manager could show the wrong rows. For example, the pager said "Page 3 of 3" but the table listed page 1's incidents. Opening the same page again could look right.

Cause: every page change sent two list requests.

  1. handlePagingClick fetched the selected page.
  2. usePaging then wrote currentPage into the URL. filters is built from every query param, so it changed too, and the fetch effect ran again with no offset, which means page 1.
  3. Whichever response came back last was shown.

A reload of ?currentPage=N also fetched page 1, because the effect never used currentPage.

What changed:

  • useIncidentManagerListPage: filters leaves out usePaging's params (currentPage, pageSize, cursorType, cursorValue). A page change no longer looks like a filter change.
  • useIncidentList:
    • One effect fetches, and it takes the offset from currentPage. A page click only calls handlePageChange.
    • Only the latest request may write rows and paging. A slow response for a page the user already left is dropped, along with any error toast it would raise.
  • useIncidentFilters: a date-range change rebuilt the query from filters, which now has no paging params. It now carries them over from the URL, so pageSize is kept; it still resets to page 1.
  • PAGING_URL_PARAMS moves to constants.ts. The test-case list, which had the same fix and its own copy of the list, now uses the shared one.

Backports: #38946 (2.0, the reported version) and #38952 (2.1).

Type of change:

  • Bug fix

High-level design:

N/A: a small bug fix in three Incident Manager hooks. It touches more than 5 files only because of tests and the moved constant.

Tests:

Use cases covered

  • Clicking Next or Previous sends one list request, at the selected page's offset, and shows that page's rows.
  • A slow response for an earlier page does not replace the rows of the page shown.
  • Loading a URL with ?currentPage=3 fetches and shows page 3.
  • Changing a filter on a later page goes back to page 1 with one request.
  • Changing the date range keeps the page size and goes back to page 1.

Unit tests

  • I added unit tests for the new/changed logic.
  • New browser test pages/IncidentManager/IncidentManagerPage.browser.test.tsx. It runs the whole app with the list API mocked, 35 incidents, and page 1 answering 1 s late.
    • Next twice sends offsets [15, 30] and shows page 3's rows. On the old code the requests were [15, 0, 30, 0].
    • A reload on page 3 sends one request at offset 30, and Previous sends one at offset 15.
    • Both tests fail on the old code. yarn test:ui:run on this file: 2 passed.
  • New Jest integration test components/IncidentManager/useIncidentManagerListPage.integration.test.tsx, with the real router, usePaging and URL filters. It covers one request per page, the URL page on first load, a late earlier response, and a filter change on page 3. Three of its tests fail on the old code.
  • Updated:
    • useIncidentList.test.ts: a click goes through handlePageChange; the fetch uses the current page's offset.
    • IncidentManager.test.tsx: a click sends no request of its own.
    • useIncidentFilters.test.ts: the date range keeps pageSize, and the helper models the new filters wiring.
  • Jest results: src/components/IncidentManager, src/components/DataQuality/TestCases and src/pages/IncidentManager all pass. Coverage % was not measured.
  • Lint and types: ESLint, Prettier and import sorting are clean on changed files. tsc reports no errors in the changed files.

Backend integration tests

  • Not applicable (no backend changes).

Ingestion integration tests

  • Not applicable (no ingestion changes).

Browser test output at 1c7e7448dce (npx vitest run --config vitest.browser.config.ts src/pages/IncidentManager/IncidentManagerPage.browser.test.tsx):

✓ |ui-integration (chromium)| src/pages/IncidentManager/IncidentManagerPage.browser.test.tsx > Incident Manager pagination > Next sends one request per page and keeps that page when page 1 answers late 2155ms
 ✓ |ui-integration (chromium)| src/pages/IncidentManager/IncidentManagerPage.browser.test.tsx > Incident Manager pagination > a reload on page 3 fetches page 3, and Previous fetches page 2 once 416ms
 Test Files  1 passed (1)
      Tests  2 passed (2)

On main's hooks the first test fails with expected [ 15, +0, 30, +0 ] to deeply equal [ 15, 30 ].

Jest at 1c7e7448dce: useIncidentManagerListPage.integration.test.tsx, useIncidentList.test.ts and useIncidentFilters.test.ts give 3 suites and 33 tests, all passed.

Playwright (UI) tests

  • Ran IncidentManagerPagination.spec.ts and DataQuality/IncidentManagerDateFilter.spec.ts at 1c7e7448dce: 16 passed, 0 failed, 0 flaky, in 2.1 min. That's 13 spec tests plus 3 setup/teardown steps.
    • Setup: this branch's UI on a vite dev server at :3000, against the local server at revision 881d635.
    • Command: PLAYWRIGHT_IS_OSS=true PLAYWRIGHT_TEST_BASE_URL=http://localhost:3000 npx playwright test playwright/e2e/Features/IncidentManagerPagination.spec.ts playwright/e2e/Features/DataQuality/IncidentManagerDateFilter.spec.ts.

Playwright report: 16 passed

  • make playwright_affected selects most of the suite, because constants.ts has no entry in .github/playwright/impact-map.json. The rest of that selection is pending for the merge queue.

Manual testing performed

  1. Local stack on :8585. Created 35 failing test cases (one open incident each) on one table, which is 3 pages at 15 per page.
  2. Ran this branch's UI with vite on :3000, proxied to :8585, and logged in as admin.
  3. In the browser I recorded every testCaseIncidentStatus/search/list request and held offset=0 responses back by 1.5 s.
  4. Old code: Next went from page 1 to 2 with requests 15, 0. Next again showed "Page 3 of 3" with 15 rows starting at the newest incident, which is page 1. This reproduces the report.
  5. This branch, same steps: one request per click (15, then 30). Page 3 shows its 5 rows. A reload of ?currentPage=3 shows page 3. Previous sends one request at offset 15.

UI screen recording:

Recorded with the UI project's Playwright (Chromium, 1440×1500) against a local OpenMetadata server.

  • Server: {"version":"2.0.0-SNAPSHOT","revision":"881d635254856ebd9ee819d10f401f74a8c95908","timestamp":1795676351225}, healthy. This is an existing dev stack, not a Docker build of this branch.
  • UI: this repo's UI served by vite on :3000 and proxied to the server.
  • Data: 35 synthetic test cases (incident-paging-check-00 … 34) on one table, each with a failed result, so 35 open incidents and 3 pages at 15 per page.
  • Steps:
    1. Log in as admin and open /incident-manager.
    2. Click Next twice.
  • Delay: the responses are real server responses. Playwright holds back the page-1 (offset=0) response by 1.5 s to reproduce the slow network that produces the race on every run.
  • Overlay: the box in the corner lists every incident list request (search/list) sent after the page loads.

Before: main @ b2365bb47e0. The requests are offset=15, 0, 30, 0. The pager says Page 3 of 3 but shows 15 rows, incident-paging-check-34 to 20, which is page 1. Page 2 shows page 1's rows too.

incident-paging-before-fix.mp4

Before fix: Page 3 of 3 lists page 1's incidents

After: this branch @ 1c7e7448dce. The requests are offset=15, 30, one per click. Page 3 of 3 shows its 5 rows, incident-paging-check-04 to 00.

incident-paging-after-fix.mp4

After fix: Page 3 of 3 lists its own five incidents

Checklist:

  • I have read CONTRIBUTING.md (the pre-review gate) and the contributor docs.

  • My PR title is Fixes <issue-number>: <short explanation>

  • My PR is linked to a GitHub issue via Fixes #<issue-number> above.

  • I have commented on my code, particularly in hard-to-understand areas.

  • For JSON Schema changes: not applicable, no schema changes.

  • For a UI feature or feature task: not applicable, this is a bug fix.

  • I have added tests (unit / integration / Playwright as applicable) and listed them above.

  • Self-review: I reviewed the final diff against REVIEW.md (the pr-checklist skill runs it) and fixed every 🔴 finding, or answered it on the line below.

    • Reviewed 300a6a8015e with a fresh reviewer: no 🔴. I applied its two 🟡 in 1c7e7448dce: dropped an unreachable same-page refetch branch and its tests, and moved a mock restore into finally. I reviewed that commit myself.
  • Decision check: no durable decision. The rule that usePaging's params stay out of URL-derived filters is in the comment on PAGING_URL_PARAMS.

  • I have added a test that covers the exact scenario we are fixing. For complex issues, comment the issue number in the test for future reference.

🤖 Generated with Claude Code

Switching pages in the Incident Manager sent two list requests: one for
the selected page and one at offset 0, because the page number lands in
the URL and the URL-derived filters then retriggered the fetch. Whichever
response came back last was shown, so page 3 could list page 1's rows.

Leave usePaging's params out of the filters, fetch from a single effect
keyed on the current page, and drop responses from superseded requests.
A date-range change keeps the page size in the URL.

Fixes #38927
NextPrevious only asks for the next or previous page, so the same-page
refetch branch in handlePagingClick was unreachable. Drop it and its
tests, and restore the usePaging mock in a finally block so a failing
assertion cannot leak currentPage 3 into later tests.
@ShaileshParmar11
ShaileshParmar11 requested a review from a team as a code owner November 27, 2026 08:33
@ShaileshParmar11
ShaileshParmar11 requested review from Rohit0301 and a balanced review from Copilot November 27, 2026 08:33
@ShaileshParmar11 ShaileshParmar11 added the UI UI specific issues label Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

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

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@gitar-bot

gitar-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Updating Incident Manager pagination and request ordering changes which incident rows are displayed; regressions could show the wrong page after navigation or filtering.

Fixes the Incident Manager showing wrong rows after paging by making each page change send one list request at the selected page's offset, and by dropping stale responses from earlier pages. Filters now exclude pagination params, and the date-range filter keeps pageSize while resetting to page 1. No issues found.

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 merged commit ed464dc into main Nov 27, 2026
53 of 55 checks passed
@ShaileshParmar11
ShaileshParmar11 deleted the ShaileshParmar11/incident-list-pagination-race branch November 27, 2026 09:59
ShaileshParmar11 added a commit that referenced this pull request Nov 27, 2026
* [2.0] Backport #35147 and fix #38927: incident list paging

Backport #35147 (reset Incident Manager pagination when filters change),
then fix the pagination race from #38927: switching pages sent a second
list request at offset 0, and whichever response came back last was
shown, so page 3 could list page 1's rows.

Leave usePaging's params out of the filters, fetch from a single effect
keyed on the current page, and drop responses from superseded requests.

(cherry picked from commit 0f7fdbf)

* test(ui): hold the old page's response in the 2.0 filter-change test

Release the old-offset response after page 1 answers, so the test fails
without the latest-request guard, and pin the two requests a filter
change sends on 2.0.

* refactor(ui): let usePaging drive every incident page change

NextPrevious only asks for the next or previous page, so the same-page
refetch branch in handlePagingClick was unreachable. Drop it and its
tests, and restore the usePaging mock in a finally block so a failing
assertion cannot leak currentPage 3 into later tests.
ShaileshParmar11 added a commit that referenced this pull request Nov 27, 2026
* fix(ui): fetch one incident page per page change

Switching pages in the Incident Manager sent two list requests: one for
the selected page and one at offset 0, because the page number lands in
the URL and the URL-derived filters then retriggered the fetch. Whichever
response came back last was shown, so page 3 could list page 1's rows.

Leave usePaging's params out of the filters, fetch from a single effect
keyed on the current page, and drop responses from superseded requests.
A date-range change keeps the page size in the URL.

Fixes #38927

(cherry picked from commit 300a6a8)

* refactor(ui): let usePaging drive every incident page change

NextPrevious only asks for the next or previous page, so the same-page
refetch branch in handlePagingClick was unreachable. Drop it and its
tests, and restore the usePaging mock in a finally block so a failing
assertion cannot leak currentPage 3 into later tests.

(cherry picked from commit 1c7e744)

* test(ui): drop the incident browser test on 2.1

2.1 has no Vitest browser setup, so the browser test cannot run there.
The Jest integration test covers the same paging behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

UI UI specific issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incident Manager list shows wrong incidents after changing page (pagination request race)

3 participants