{"record":{"id":"53d5ad351bb8ec61","repo":"Significant-Gravitas/AutoGPT","slug":"page-size-must-be-greater-than-0","errorCode":null,"errorMessage":"Page size must be greater than 0","messagePattern":"Page size must be greater than 0","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/external/v1/routes.py","lineNumber":352,"sourceCode":"    Get a paginated list of agents from the store with optional filtering and sorting.\n\n    Args:\n        featured: Filter to only show featured agents\n        creator: Filter agents by creator username\n        sorted_by: Sort agents by \"runs\", \"rating\", \"name\", or \"updated_at\"\n        search_query: Search agents by name, subheading and description\n        category: Filter agents by category\n        page: Page number for pagination (default 1)\n        page_size: Number of agents per page (default 20)\n\n    Returns:\n        StoreAgentsResponse: Paginated list of agents matching the filters\n    \"\"\"\n    if page < 1:\n        raise HTTPException(status_code=422, detail=\"Page must be greater than 0\")\n\n    if page_size < 1:\n        raise HTTPException(status_code=422, detail=\"Page size must be greater than 0\")\n\n    agents = await store_cache._get_cached_store_agents(\n        featured=featured,\n        creator=creator,\n        sorted_by=sorted_by,\n        search_query=search_query,\n        category=category,\n        page=page,\n        page_size=page_size,\n    )\n    return agents\n\n\n@v1_router.get(\n    path=\"/store/agents/{username}/{agent_name}\",\n    tags=[\"store\"],\n    dependencies=[Security(require_auth)],  # data is public; auth required as anti-DDoS\n    response_model=store_model.StoreAgentDetails,","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/v1/routes.py#L334-L370","documentation":"HTTP 422 from GET /api/v1/store/agents (external store API). The `page_size` query parameter was parsed as an integer but is < 1 (0 or negative), failing the route's manual check. The store cache lookup is never reached.","triggerScenarios":"GET /api/v1/store/agents?page_size=0, ?page_size=-5, or a page_size computed from an empty list length (e.g. total/total=0) in client code.","commonSituations":"Dynamic page sizing where size derives from a result count that is 0; UI 'items per page' selector allowing an empty/zero entry; env-configured page size defaulting to 0 when unset.","solutions":["Send a positive page_size (default is 20).","Guard dynamic sizes client-side: page_size = Math.max(1, computedSize).","Treat unset/0 configuration as the default 20 rather than forwarding it."],"exampleFix":"// before\nconst size = list.length ? 20 : list.length; // sends 0\n\n// after\nconst size = 20; // keep a positive constant default","handlingStrategy":"validation","validationCode":"const pageSize = Number.isInteger(raw) && raw >= 1 ? raw : 20;","typeGuard":"function isValidPageSize(n: number): boolean { return Number.isInteger(n) && n >= 1; }","tryCatchPattern":null,"preventionTips":["Never derive page_size from result counts.","Fall back to the documented default (20) when the value is unset or 0."],"tags":["http-422","pagination","store-api","validation"],"backgroundTag":null,"analyzedSha":"9c8bb5550f446ba5d3046b78896578742495b3cf","analyzedAt":"2026-08-14T17:17:21.957Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}