{"record":{"id":"b3e9e7a675cd17d2","repo":"ruvnet/RuView","slug":"size-must-be-max-size","errorCode":null,"errorMessage":"Size must be <= {max_size}","messagePattern":"Size must be <= (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"archive/v1/src/api/dependencies.py","lineNumber":350,"sourceCode":"        self,\n        page: int = 1,\n        size: int = 20,\n        max_size: int = 100\n    ):\n        if page < 1:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=\"Page must be >= 1\"\n            )\n        \n        if size < 1:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=\"Size must be >= 1\"\n            )\n        \n        if size > max_size:\n            raise HTTPException(\n                status_code=status.HTTP_400_BAD_REQUEST,\n                detail=f\"Size must be <= {max_size}\"\n            )\n        \n        self.page = page\n        self.size = size\n        self.offset = (page - 1) * size\n        self.limit = size\n\n\ndef get_pagination_params(\n    page: int = 1,\n    size: int = 20\n) -> PaginationParams:\n    \"\"\"Get pagination parameters.\"\"\"\n    return PaginationParams(page=page, size=size)\n\n","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/archive/v1/src/api/dependencies.py#L332-L368","documentation":"Raised as HTTP 400 by PaginationParams at dependencies.py:350 when `size` exceeds `max_size` (default 100). The cap protects the service and database from oversized single responses. The detail is an f-string, so the wire message reads e.g. 'Size must be <= 100'.","triggerScenarios":"?size=101 or higher on any endpoint using get_pagination_params with the default max_size=100, or exceeding a custom max_size a route passes to PaginationParams.","commonSituations":"A dashboard tries to load a full table in one request; the server team changed max_size and a deployed client still sends the old page size; copying a size from another endpoint with a different cap.","solutions":["Request at most 100 items per page and follow pagination for the remainder","Page through with page/size instead of one oversized request","If you operate the server and must allow bigger pages, raise max_size where the dependency constructs PaginationParams (get_pagination_params) rather than deleting the check"],"exampleFix":"# before\nparams = PaginationParams(page=page, size=size)\n\n# after (allow up to 500 on this route)\nparams = PaginationParams(page=page, size=size, max_size=500)","handlingStrategy":"validation","validationCode":"MAX_PAGE_SIZE = 100\nsize = min(int(desired_size), MAX_PAGE_SIZE)  # page through for the remainder","typeGuard":"def is_valid_size(size, max_size=100) -> bool:\n    return isinstance(size, int) and 1 <= size <= max_size","tryCatchPattern":"resp = await client.get('/api/v1/detections', params=params)\nif resp.status_code == 400 and 'Size must be <=' in resp.json().get('detail', ''):\n    params['size'] = 100\n    resp = await client.get('/api/v1/detections', params=params)\nresp.raise_for_status()","preventionTips":["Discover the cap once (from the 400 detail) and cache it in the client","Never assume unlimited — implement paging from day one","Keep the server's max_size in one documented config location"],"tags":["python","fastapi","pagination","validation","http-400"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}