Repository navigation
Fixes 35037: Prevent negative offsets from UI pagination - #35040
Conversation
Clamp zero and negative page numbers in regular and natural-language UI searches to the first page, preserving valid pagination and count-only requests. Add Jest regression coverage for the request offsets and a Playwright regression for a Queries-tab URL with queryFrom=0&pageSize=25. Refs #35037. Backend request validation is handled separately in #35039.
Code Review ✅ Approved🟡 Medium risk · Clamping page numbers in shared search builders changes pagination for zero or negative inputs; malformed URLs may show first-page results instead of failing. Clamps the page number to at least 1 in the regular and natural-language search request builders so page-zero URLs such as OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
❌ UI Checkstyle Failed❌ Bundle Runtime CheckA route chunk loads but one of its chunks still exports Fix locally (fast - only checks files changed in this branch): make ui-checkstyle-changed |
|
The pagination tests from #35040 mock ./axiosClient, which only exists on main. On 2.0 searchAPI imports its client from ./index, so the mock could not resolve and all 12 new cases failed. Mock ./index like the rest of the file.
…ted failures logged as errors [2.0] (#35302) * Fixes #35037: reject negative search pagination before it reaches the engine [2.0] Backport of #35039 and #35040. A negative from or size on the search endpoints is rejected with a 400 that names the parameter instead of failing in the search engine as a 500, and the UI no longer sends a negative offset. SearchResourceIT conflicted: 2.0 has neither the httpGetSearch helper nor the 400 mapping the old negative-offset test expected, so the new tests and helpers were added by hand. (cherry picked from commit 893cd1b) (cherry picked from commit e3914c5) * Fixes #35293: serve glossary CSV documentation for glossary-term import [2.0] The bulk import page asks /v1/csv/documentation/{entityType} for the type it imports into. For a glossary term that is glossaryTerm, which has no documentation file, so every request returned a 500 and was logged twice at ERROR. Glossary-term import already goes through GlossaryCsv, so glossaryTerm now gets the glossary's documentation. A type with no documentation returns a 404, and the FATAL log before the rethrow is gone. * Apply a workflow approval when the approver is not a reviewer [2.0] Anyone the task policy lets resolve an approval task, such as an admin or an owner, could approve a glossary term without being one of its reviewers. The workflow then set the status as that user, the reviewer check rejected it, and the failure was only logged: the task closed as Approved while the term stayed In Review. As on main since #34541, a status change the governance workflow makes, as or impersonating governance-bot, skips the reviewer check: the approval task already decided who may approve. Direct edits are still checked. SetGlossaryTermStatusImpl now writes impersonating governance-bot like the other workflow nodes, so its changes are recognised too. * Skip deleted alert recipients without logging an error [2.0] An alert can name a user or team that is deleted later. Every event for that alert logged the lookup failure at ERROR with a stack trace, although there is simply no one left to notify. A missing recipient is now skipped at DEBUG, as main does since #33967; any other lookup failure is still logged as an error. * Mock the 2.0 API client in the backported pagination test The pagination tests from #35040 mock ./axiosClient, which only exists on main. On 2.0 searchAPI imports its client from ./index, so the mock could not resolve and all 12 new cases failed. Mock ./index like the rest of the file. * Verify the impersonated status patch in BatchModeNodesTest #35239 brought this test to 2.0 while this branch made SetGlossaryTermStatusImpl patch impersonating governance-bot, so the test still expected the plain four-argument patch. It now checks the same call main's copy of the test does.



Describe your changes:
Fixes #35037 (UI portion; backend validation is covered by #35039).
A page-zero URL such as a table's Queries tab with
queryFrom=0&pageSize=25makes the UI calculatefrom=(0-1)*25, sendingfrom=-25to search. The request fails and the queries do not load.Clamp the page number to at least 1 when constructing regular and natural-language search requests. Page zero and negative pages now request the first page; valid pagination and count-only requests (
size=0) retain their behavior. Add Jest coverage for both helpers and a Playwright regression that reloads the Queries tab from a page-zero URL and checks the request, response, and visible query.This PR contains the UI fix and frontend tests from commit
3d9c665b1b64. The complementary backend fix in #35039 rejects negative offsets and sizes at the API boundary.Type of change:
High-level design:
N/A — small change to two shared request builders and their regression tests.
Tests:
Use cases covered
0, negative page, first page, second page, omitted page, andsize=0.queryFrom=0&pageSize=25sendsfrom=0, receives HTTP 200, and displays the existing query.Unit tests
openmetadata-ui/src/main/resources/ui/src/rest/searchAPI.test.ts.yarn test src/rest/searchAPI.test.ts --runInBand --watch=false: 16 passed, including 12 new parameterized cases. The suite failed before the fix and passed after it.--coverage --collectCoverageFrom=src/rest/searchAPI.ts --coverageReporters=text-summary --coverageReporters=json-summary: 16 passed. Whole-file line coverage is 63.88% (46/72); statements 65.93%, branches 51.28%, functions 33.33%. Both changed offset expressions are exercised. Whole-file coverage remains below the repository's 90% target.yarn lint:playwright: 0 errors, 201 existing warnings.yarn tsc:checkandyarn tsc:playwrightremain blocked by existing type errors. The application check reported 581 diagnostics; comparison with the base version of the changed source found no new diagnostic locations. The Playwright errors include the existingQueryEntity.spec.ts:55table type mismatch.Backend integration tests
Local Java test run: NOT NEEDED — no Java unit or integration test is impacted.
3d9c665b1b64(baseorigin/main)Ingestion integration tests
Playwright (UI) tests
Load queries from a URL with page zerotoopenmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts.PW_PRESEEDED_STATE=true \ PLAYWRIGHT_TEST_BASE_URL=http://127.0.0.1:3002 \ PLAYWRIGHT_IS_OSS=true PW_TRACE=on \ yarn playwright:run playwright/e2e/Features/QueryEntity.spec.ts \ --project=chromium --grep 'Load queries from a URL with page zero' \ --workers=1 --no-deps --reporter=listLocal Playwright validation: PARTIAL — draft
make playwright_affectedselects 22 specs and reports impact-map gaps forsrc/rest/searchAPI.tsandsrc/rest/searchAPI.test.ts(full-suite fallback).Manual testing performed
No separate manual browser pass. The automated browser test performs these reproducible steps:
queryFrom=0&pageSize=25.from=0, returns HTTP 200, and the same query remains visible.UI screen recording / screenshots:
TODO: attach a recording of the page-zero URL regression before marking ready. This PR is a draft.
Checklist:
Fixes <issue-number>: <short explanation>.Fixes #<issue-number>above.