Cap search pagination at the OpenSearch result window; surface search errors - #1683
Open
JasonWildMe wants to merge 3 commits into
Open
Cap search pagination at the OpenSearch result window; surface search errors#1683JasonWildMe wants to merge 3 commits into
JasonWildMe wants to merge 3 commits into
Conversation
… errors - DataTable offers only pages inside index.max_result_window (via the X-Wildbook-Max-Result-Window header when available, defaulting to 10000) instead of terminal page links the backend can never serve; when capped, a localized notice explains that only the first N results are browsable - the "Go to page" input honors the same ceiling - an error state now renders a localized "search failed" message instead of a misleading "No results found" empty table - useFilterEncounters exposes the window header and no longer retries 4xx responses (deterministic failures were retried twice per click) - new UI copy localized in de/en/es/fr/it Fixes #1681 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- pageCount uses floor for capped result sets so the final offered page's from+size never straddles the window (window 10000 at 30/page previously offered page 334 = from 9990 + size 30 = 10020, refused by the backend); partial last pages remain for result sets inside the window - browsableItemCount reports the actually reachable item count (pages x perPage when capped) so the capped notice is accurate - changing per-page resets to the first page, and a clamp effect snaps the page back whenever the browsable page count drops below it; forcePage is clamped to the cap Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ero pages - the query-ID search now reads x-wildbook-max-result-window from its OWN response and the table receives the branch-appropriate limit, so stored searches on indexes with a raised window are no longer capped at 10k (and smaller windows can no longer offer invalid pages) - the paginator is not rendered when the browsable page count is zero, avoiding react-paginate's controlled-page warning during initial load Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1683 +/- ##
==========================================
- Coverage 51.49% 51.49% -0.01%
==========================================
Files 311 312 +1
Lines 12261 12299 +38
Branches 3956 3865 -91
==========================================
+ Hits 6314 6333 +19
- Misses 5665 5683 +18
- Partials 282 283 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
naknomum
self-requested a review
July 15, 2026 20:32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1681
Companion to #1682 (backend), which adds the
X-Wildbook-Max-Result-Windowheader this PR consumes. Works standalone too — a 10,000 default applies when the header is absent.What
utils/resultWindow.js(new): pure pagination-window math. Inside the window a partial last page is kept; when the result set exceeds the window, only full pages are offered so no request can straddle the ceiling (e.g. window 10,000 at 30/page previously implied page 334 →from=9990&size=30= 10,020, which the backend refuses).DataTable.jsx: the paginator and "Go to page" input offer only browsable pages; when results are capped, a localized notice explains that only the first N of M results can be browsed; anerrorprop renders a localized "search failed" message instead of a misleading "No results found"; changing per-page resets to page 1 and a clamp effect snaps the page back if the browsable count shrinks; the paginator is not rendered at zero pages.useFilterEncounters.js: exposes the window header, and retries only transport/5xx failures — a deterministic 4xx (like a pagination rejection) is no longer retried twice per click.EncounterSearch.jsx: passes error state and the per-branch window limit (the stored-query path reads the header from its own response).Why
Production incident 2026-07-10: for >window search results the UI offered terminal page links the backend can never serve; the resulting 500 was swallowed into an empty "No results found" table, so the user retried repeatedly — each click costing 3 requests (react-query retry) × 6 OpenSearch executions (backend retry bug, fixed in #1682).
Tests / verification
resultWindow.test.js: 11 cases including the straddle case, per-index 12,004 window, boundary and invalid inputs. All green.react-hooks/exhaustive-depsclean on all touched code).Follow-up (out of scope, noted in #1681):
search_aftercursor pagination to make all results browsable.🤖 Generated with Claude Code