Skip to content

Fixes 35037: Prevent negative offsets from UI pagination - #35040

Merged
harshach merged 1 commit into
mainfrom
agent/analyze-why-this-error-happe
Oct 9, 2026
Merged

harshach merged 1 commit into
mainfrom
agent/analyze-why-this-error-happe

Conversation

@harshach

@harshach harshach commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

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=25 makes the UI calculate from=(0-1)*25, sending from=-25 to 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:

  • Bug fix

High-level design:

N/A — small change to two shared request builders and their regression tests.

Tests:

Use cases covered

  • Regular and natural-language searches: page 0, negative page, first page, second page, omitted page, and size=0.
  • Reloading a table's Queries tab with queryFrom=0&pageSize=25 sends from=0, receives HTTP 200, and displays the existing query.

Unit tests

  • Added regression cases in 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 run: the same command with --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.
  • Changed-file organize-imports, ESLint, and Prettier checks passed. Pre-commit checks passed.
  • yarn lint:playwright: 0 errors, 201 existing warnings.
  • yarn tsc:check and yarn tsc:playwright remain 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 existing QueryEntity.spec.ts:55 table type mismatch.

Backend integration tests

Local Java test run: NOT NEEDED — no Java unit or integration test is impacted.

  • Commit: 3d9c665b1b64 (base origin/main)

Ingestion integration tests

  • Not applicable — no ingestion changes.

Playwright (UI) tests

  • Added Load queries from a URL with page zero to openmetadata-ui/src/main/resources/ui/playwright/e2e/Features/QueryEntity.spec.ts.
  • Focused Chromium regression: 1 passed against the locally built backend, PostgreSQL 15, OpenSearch 3.4.0, and Vite UI. Test data is created and cleaned up by the existing spec fixtures.
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=list

Local Playwright validation: PARTIAL — draft

  • Focused new regression: 1 passed. UI code and test are unchanged since that run.
  • make playwright_affected selects 22 specs and reports impact-map gaps for src/rest/searchAPI.ts and src/rest/searchAPI.test.ts (full-suite fallback).
  • The full affected suite has not been run; the focused regression used the local development stack. Resolve the selection gaps and complete the broader run before marking ready.

Manual testing performed

No separate manual browser pass. The automated browser test performs these reproducible steps:

  1. Sign in as admin and open a table with an existing query.
  2. Open its Queries tab and confirm the query is visible.
  3. Reload its URL with queryFrom=0&pageSize=25.
  4. Confirm the search request uses 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:

  • I have read the CONTRIBUTING document.
  • 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. N/A — the arithmetic change is self-explanatory.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed. N/A — no schema changes.
  • For UI changes: I attached a screen recording and/or screenshots above.
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Decision check: no new decision record is needed for this small bug fix; page 1 is already the helpers' default and the regression tests capture the corrected behavior.
  • I have added a test that covers the exact page-zero scenario we are fixing.

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.
@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 9, 2026
@gitar-bot

gitar-bot Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
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 queryFrom=0&pageSize=25 no longer send a negative from offset. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

🤖 Auto-approval Not enabled · Set up

Options

Display: compact → Counting what did not apply, without listing it.

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

@harshach
harshach marked this pull request as ready for review October 9, 2026 14:57
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

❌ UI Checkstyle Failed

❌ Bundle Runtime Check

A route chunk loads but one of its chunks still exports undefined: a chunking change broke module initialisation. Run yarn build && yarn bundle:runtime locally.


Fix locally (fast - only checks files changed in this branch):

make ui-checkstyle-changed

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Jest test Coverage

UI tests summary

Lines Statements Branches Functions
Coverage: 76%
76.32% (120413/157768) 62.28% (74589/119750) 63.71% (24909/39094)

@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@harshach
harshach added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit e3914c5 Oct 9, 2026
129 of 131 checks passed
@harshach
harshach deleted the agent/analyze-why-this-error-happe branch October 9, 2026 19:07
mohityadav766 added a commit that referenced this pull request Oct 13, 2026
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.
mohityadav766 added a commit that referenced this pull request Oct 13, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative from/size on search endpoints reach the search engine and fail as a server error

2 participants