{"record":{"id":"d72e5a99e9170fa8","repo":"Significant-Gravitas/AutoGPT","slug":"page-must-be-greater-than-0","errorCode":null,"errorMessage":"Page must be greater than 0","messagePattern":"Page must be greater than 0","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"warning","filePath":"autogpt_platform/backend/backend/api/external/v1/routes.py","lineNumber":349,"sourceCode":"    page_size: int = 20,\n) -> store_model.StoreAgentsResponse:\n    \"\"\"\n    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}\",","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/Significant-Gravitas/AutoGPT/blob/9c8bb5550f446ba5d3046b78896578742495b3cf/autogpt_platform/backend/backend/api/external/v1/routes.py#L331-L367","documentation":"HTTP 422 from GET /api/v1/store/agents (external store API). The route manually validates the `page` query parameter after FastAPI parsing: any integer < 1 (i.e. 0 or negative) is rejected. FastAPI only enforces the int type, so page=0 passes parsing and hits this explicit check.","triggerScenarios":"GET /api/v1/store/agents?page=0 or ?page=-2. Also generated clients that default page to 0 (zero-based paging conventions) or compute page as offset/page_size which yields 0 for the first page.","commonSituations":"Porting a client from a zero-based pagination API to this one-based API; frontend pager components initialized with currentPage=0; passing an uninitialized int before the state loads.","solutions":["Use 1-based paging: the first page is page=1.","If your client is zero-based, send page=zero_based_page+1.","Clamp before sending: page = max(1, requested_page)."],"exampleFix":"// before\nconst res = await fetch(`/api/v1/store/agents?page=${pageIndex}`); // pageIndex starts at 0\n\n// after\nconst res = await fetch(`/api/v1/store/agents?page=${pageIndex + 1}`);","handlingStrategy":"validation","validationCode":"const page = Math.max(1, rawPage); // enforce 1-based before fetch","typeGuard":"function isValidPage(p: number): boolean { return Number.isInteger(p) && p >= 1; }","tryCatchPattern":null,"preventionTips":["Treat page as 1-based everywhere in the client.","Centralize query-string building for store endpoints in one helper that clamps page and page_size."],"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"}