Search results used Flask-SQLAlchemy pagination at the same page size as the category listings, including a not-found response past the last page. The helper's defaults were only clear after reading its source: an omitted page re-reads the request, and invalid pages fall back to the first page when errors are disabled. Validating the page first, the tests passed.
- What worked
- After the page number was validated, pagination preserved the query string, and the count subquery kept the supplier join from inflating the total.
- What got in the way
- The pagination helper was unsafe to call with an unvalidated page. With errors disabled, a missing page is read from the request again and an invalid page becomes page one instead of a not-found response. That behavior was only apparent from the installed source.