{"record":{"id":"7b673a1d70a97166","repo":"chroma-core/chroma","slug":"limit-can-only-be-specified-when-a-where-or-where","errorCode":null,"errorMessage":"limit can only be specified when a where or where_document clause is provided","messagePattern":"limit can only be specified when a where or where_document clause is provided","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/models/CollectionCommon.py","lineNumber":484,"sourceCode":"        self,\n        ids: Optional[IDs],\n        where: Optional[Where],\n        where_document: Optional[WhereDocument],\n        limit: Optional[int] = None,\n    ) -> DeleteRequest:\n        if ids is None and where is None and where_document is None:\n            raise ValueError(\n                \"At least one of ids, where, or where_document must be provided\"\n            )\n\n        if limit is not None:\n            if not isinstance(limit, int) or isinstance(limit, bool):\n                raise TypeError(\"limit must be a non-negative integer\")\n            if limit < 0:\n                raise ValueError(\"limit must be a non-negative integer\")\n\n        if limit is not None and where is None and where_document is None:\n            raise ValueError(\n                \"limit can only be specified when a where or where_document clause is provided\"\n            )\n\n        # Unpack\n        if ids is not None:\n            request_ids = cast(IDs, maybe_cast_one_to_many(ids))\n        else:\n            request_ids = None\n        filters = FilterSet(where=where, where_document=where_document)\n\n        # Validate\n        if request_ids is not None:\n            validate_ids(ids=request_ids)\n        validate_filter_set(filter_set=filters)\n\n        return DeleteRequest(\n            ids=request_ids, where=where, where_document=where_document, limit=limit\n        )","sourceCodeStart":466,"sourceCodeEnd":502,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/models/CollectionCommon.py#L466-L502","documentation":"`limit` on delete only bounds a predicate-based delete. It has no meaning for delete-by-ids (ids are explicit and unordered), so passing limit together with ids but no where/where_document is rejected.","triggerScenarios":"`collection.delete(ids=[\"a\", \"b\"], limit=5)` — ids provided, where and where_document None.","commonSituations":"Reusing a kwargs dict built for a filtered delete and adding ids; assuming limit applies to batched id deletion.","solutions":["Remove the limit argument when deleting by ids","If you want to bound how many ids are deleted, slice the list yourself: `collection.delete(ids=ids[:100])`","If you want bounded predicate deletion, supply where or where_document alongside limit"],"exampleFix":"# before\ncollection.delete(ids=batch_ids, limit=100)  # ValueError\n\n# after\ncollection.delete(ids=batch_ids[:100])","handlingStrategy":"validation","validationCode":"if limit is not None and where is None and where_document is None:\n    limit = None  # limit is meaningless for id-only deletes\ncollection.delete(ids=ids, where=where, where_document=where_document, limit=limit)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply limit only on predicate deletes","Bound id-based deletes by slicing the ids list yourself","Keep delete kwargs construction explicit rather than reusing a shared dict"],"tags":["limit","delete","parameter-conflict"],"backgroundTag":"conflicting-parameters","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}