{"record":{"id":"950f02e0de3b7dc6","repo":"VectifyAI/PageIndex","slug":"limit-must-be-between-1-and-100-950f02","errorCode":null,"errorMessage":"limit must be between 1 and 100","messagePattern":"limit must be between 1 and 100","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pageindex/local_api.py","lineNumber":352,"sourceCode":"        meta = self._store.get_meta(doc_id)\n        if meta is None:\n            raise PageIndexAPIError(\"Failed to get document metadata: Document not found\")\n        return {key: meta.get(key) for key in\n                (\"id\", \"name\", \"description\", \"status\", \"createdAt\", \"pageNum\", \"folderId\")}\n\n    def delete_document(self, doc_id: str) -> dict[str, Any]:\n        if not self._store.delete_document(doc_id):\n            raise PageIndexAPIError(\"Failed to delete document: Document not found.\")\n        return {\"message\": \"Document deleted successfully.\"}\n\n    def list_documents(\n        self,\n        limit: int = 50,\n        offset: int = 0,\n        folder_id: str | None = None,\n    ) -> dict[str, Any]:\n        if limit < 1 or limit > 100:\n            raise ValueError(\"limit must be between 1 and 100\")\n        if offset < 0:\n            raise ValueError(\"offset must be non-negative\")\n        if folder_id is not None:\n            raise PageIndexAPIError(\n                \"Failed to list documents: folders are not supported in local mode.\"\n            )\n        metas = sorted(self._store.list_metas(), key=lambda m: m.get(\"id\") or \"\")\n        metas.sort(key=lambda m: m.get(\"createdAt\") or \"\", reverse=True)\n        documents = [{\n            \"id\": m.get(\"id\"),\n            \"name\": m.get(\"name\"),\n            \"description\": m.get(\"description\"),\n            \"status\": m.get(\"status\"),\n            \"createdAt\": m.get(\"createdAt\"),\n            \"pageNum\": m.get(\"pageNum\", 0),\n            \"folderId\": None,\n            \"metadata\": m.get(\"metadata\"),\n            \"features\": {},","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/VectifyAI/PageIndex/blob/afb5e119766630af6014b04fe8b53357527bc05e/pageindex/local_api.py#L334-L370","documentation":"list_documents validates pagination bounds before querying the store: limit must be an integer in [1, 100]. It raises ValueError (not PageIndexAPIError) so bad arguments surface as programmer errors rather than API failures.","triggerScenarios":"Calling list_documents(limit=0), limit=-5, limit=101, or limit=200 expecting full listing.","commonSituations":"Porting code from an API with different page-size caps, hardcoding large limits for 'give me everything', passing limit computed as len(items) that can exceed 100.","solutions":["Clamp limit to the 1-100 window, e.g. limit = max(1, min(100, desired))","Page through results with limit=100 and increasing offset instead of one big limit","Validate user-supplied page sizes at your API boundary before forwarding"],"exampleFix":"# before\nclient.list_documents(limit=500)\n\n# after\nclient.list_documents(limit=100, offset=0)  # page in chunks of 100","handlingStrategy":"validation","validationCode":"limit = max(1, min(100, int(limit or 50)))\ndocs = client.list_documents(limit=limit, offset=offset)","typeGuard":"def is_valid_limit(limit) -> bool:\n    return isinstance(limit, int) and not isinstance(limit, bool) and 1 <= limit <= 100","tryCatchPattern":"null","preventionTips":["Centralize pagination clamping in one helper","Never trust UI page-size inputs; clamp at the boundary","Page with limit=100 + offset loops instead of large limits"],"tags":["pageindex","pagination","validation","valueerror"],"backgroundTag":"pagination-limit-out-of-range","analyzedSha":"afb5e119766630af6014b04fe8b53357527bc05e","analyzedAt":"2026-08-27T11:20:48.519Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}