Significant-Gravitas/AutoGPT · warning · DatabaseError
Invalid page size
Error message
Invalid page size
What it means
Raised in get_store_creators when page_size is not an int, is less than 1, or exceeds 100. The cap of 100 is a deliberate server-side limit to bound query cost; it is checked before the count query runs. Like its siblings it is raised as DatabaseError but is really a 4xx-class validation failure.
Source
Thrown at autogpt_platform/backend/backend/api/features/store/db.py:532
.replace('"', '\\"')
.replace(";", "\\;")
.replace("--", "\\--")
.replace("/*", "\\/*")
.replace("*/", "\\*/")
)
where["OR"] = [
{"username": {"contains": sanitized_query, "mode": "insensitive"}},
{"name": {"contains": sanitized_query, "mode": "insensitive"}},
{"description": {"contains": sanitized_query, "mode": "insensitive"}},
]
try:
# Validate pagination parameters
if not isinstance(page, int) or page < 1:
raise DatabaseError("Invalid page number")
if not isinstance(page_size, int) or page_size < 1 or page_size > 100:
raise DatabaseError("Invalid page size")
# Get total count for pagination using sanitized where clause
total = await prisma.models.Creator.prisma().count(
where=prisma.types.CreatorWhereInput(**where)
)
total_pages = (total + page_size - 1) // page_size
# Add pagination with validated parameters
skip = (page - 1) * page_size
take = page_size
order: prisma.types.CreatorOrderByInput = (
{"agent_rating": "desc"}
if sorted_by == StoreCreatorsSortOptions.AGENT_RATING
else (
{"agent_runs": "desc"}
if sorted_by == StoreCreatorsSortOptions.AGENT_RUNS
else (View on GitHub (pinned to 9c8bb5550f)
Solutions
- Clamp the value: page_size = min(100, max(1, int(page_size))).
- Constrain the API param with Query(ge=1, le=100) so invalid values are rejected as 422 at the route boundary.
- Replace 'show all' UX with paginated or infinite-scroll fetching.
Example fix
# before
@router.get('/creators')
async def creators(page_size: int = 20): ...
# after
from fastapi import Query
@router.get('/creators')
async def creators(page_size: int = Query(20, ge=1, le=100)): ... Defensive patterns
Strategy: validation
Validate before calling
const ALLOWED_SIZES = [10, 20, 50, 100]; const pageSize = ALLOWED_SIZES.includes(requested) ? requested : 20;
Type guard
function isValidPageSize(n: unknown): boolean {
return Number.isInteger(n) && (n as number) >= 1 && (n as number) <= 100;
} Prevention
- Offer fixed page-size options instead of free numeric entry.
- Never pass total_items as page_size for 'show all' — paginate or infinite-scroll instead.
- Declare le=100 on the route parameter.
When it happens
Trigger: GET /store/creators?page_size=0, ?page_size=500, or calling get_store_creators(page_size=None) directly. UIs with a 'show all' option that passes total_items as page_size are a classic source.
Common situations: A 'load all' button passing the total count; a page-size selector allowing arbitrary numeric entry; tests using large fixture page sizes.
Related errors
- Invalid page number
- Page must be greater than 0
- Page size must be greater than 0
- Failed to fetch store agents
- Invalid search query
AI-assisted analysis of Significant-Gravitas/AutoGPT@9c8bb5550f (2026-08-14).
Data as JSON: /api/errors/2579c3bab712e541.
Report an issue: GitHub.