{"record":{"id":"2579c3bab712e541","repo":"Significant-Gravitas/AutoGPT","slug":"invalid-page-size","errorCode":null,"errorMessage":"Invalid page size","messagePattern":"Invalid page size","errorType":"exception","errorClass":"DatabaseError","httpStatus":500,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/features/store/db.py","lineNumber":532,"sourceCode":"            .replace('\"', '\\\\\"')\n            .replace(\";\", \"\\\\;\")\n            .replace(\"--\", \"\\\\--\")\n            .replace(\"/*\", \"\\\\/*\")\n            .replace(\"*/\", \"\\\\*/\")\n        )\n\n        where[\"OR\"] = [\n            {\"username\": {\"contains\": sanitized_query, \"mode\": \"insensitive\"}},\n            {\"name\": {\"contains\": sanitized_query, \"mode\": \"insensitive\"}},\n            {\"description\": {\"contains\": sanitized_query, \"mode\": \"insensitive\"}},\n        ]\n\n    try:\n        # Validate pagination parameters\n        if not isinstance(page, int) or page < 1:\n            raise DatabaseError(\"Invalid page number\")\n        if not isinstance(page_size, int) or page_size < 1 or page_size > 100:\n            raise DatabaseError(\"Invalid page size\")\n\n        # Get total count for pagination using sanitized where clause\n        total = await prisma.models.Creator.prisma().count(\n            where=prisma.types.CreatorWhereInput(**where)\n        )\n        total_pages = (total + page_size - 1) // page_size\n\n        # Add pagination with validated parameters\n        skip = (page - 1) * page_size\n        take = page_size\n\n        order: prisma.types.CreatorOrderByInput = (\n            {\"agent_rating\": \"desc\"}\n            if sorted_by == StoreCreatorsSortOptions.AGENT_RATING\n            else (\n                {\"agent_runs\": \"desc\"}\n                if sorted_by == StoreCreatorsSortOptions.AGENT_RUNS\n                else (","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/features/store/db.py#L514-L550","documentation":"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.","triggerScenarios":"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.","commonSituations":"A 'load all' button passing the total count; a page-size selector allowing arbitrary numeric entry; tests using large fixture page sizes.","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."],"exampleFix":"# before\n@router.get('/creators')\nasync def creators(page_size: int = 20): ...\n# after\nfrom fastapi import Query\n@router.get('/creators')\nasync def creators(page_size: int = Query(20, ge=1, le=100)): ...","handlingStrategy":"validation","validationCode":"const ALLOWED_SIZES = [10, 20, 50, 100];\nconst pageSize = ALLOWED_SIZES.includes(requested) ? requested : 20;","typeGuard":"function isValidPageSize(n: unknown): boolean {\n  return Number.isInteger(n) && (n as number) >= 1 && (n as number) <= 100;\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["validation","pagination","store"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}