getredash/redash · error
Page must be positive integer.
Error message
Page must be positive integer.
What it means
Raised by the shared paginate() helper in redash/handlers/base.py when the requested page number is less than 1. All paginated Redash list endpoints (queries, dashboards, alerts, etc.) route through this helper, so any request with page=0 or a negative page value is rejected with HTTP 400.
Source
Thrown at redash/handlers/base.py:84
if f not in req:
abort(400)
def get_object_or_404(fn, *args, **kwargs):
try:
rv = fn(*args, **kwargs)
if rv is None:
abort(404)
except NoResultFound:
abort(404)
return rv
def paginate(query_set, page, page_size, serializer, **kwargs):
count = query_set.count()
if page < 1:
abort(400, message="Page must be positive integer.")
if (page - 1) * page_size + 1 > count > 0:
abort(400, message="Page is out of range.")
if page_size > 250 or page_size < 1:
abort(400, message="Page size is out of range (1-250).")
results = query_set.paginate(page, page_size)
# support for old function based serializers
if isclass(serializer):
items = serializer(results.items, **kwargs).serialize()
else:
items = [serializer(result) for result in results.items]
return {"count": count, "page": page, "page_size": page_size, "results": items}
View on GitHub (pinned to ca79fe988d)
Solutions
- Use 1-based page numbers: the first page is page=1, not page=0.
- If computing from an offset, use page = offset // page_size + 1.
- Validate/clamp page >= 1 before sending the request.
Example fix
# before
resp = client.get('/api/queries?page=0&page_size=25')
# after
resp = client.get('/api/queries?page=1&page_size=25') Defensive patterns
Strategy: validation
Validate before calling
page = max(1, int(page_arg))
params = {'page': page, 'page_size': 25} Prevention
- Treat Redash pagination as 1-based everywhere in the client.
- Centralize query-string building for paginated calls so the clamp lives in one place.
When it happens
Trigger: Calling any list endpoint with ?page=0, ?page=-1, or a non-numeric page coerced to a value below 1 (e.g. ?page=abc handled upstream as 0). Also passing page as an empty string default when a caller omits required parameters.
Common situations: Client code computing page from an offset (offset/page_size) that yields 0 for the first batch instead of 1; UI components sending a 0-based page index to a 1-based API.
Related errors
- Page is out of range.
- Page size is out of range (1-250).
- Unknown 'pagination.type' {}
- 'pagination.path' should be a string
- 'pagination.fields' should be a list of 2 field names
AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28).
Data as JSON: /api/errors/384ef60716507c44.
Report an issue: GitHub.