{"record":{"id":"c36e5f614b696cdf","repo":"chroma-core/chroma","slug":"limit-must-be-a-non-negative-integer-c36e5f","errorCode":null,"errorMessage":"limit must be a non-negative integer","messagePattern":"limit must be a non-negative integer","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"chromadb/api/models/CollectionCommon.py","lineNumber":479,"sourceCode":"            uris=upsert_records[\"uris\"],\n        )\n\n    @validation_context(\"delete\")\n    def _validate_and_prepare_delete_request(\n        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)","sourceCodeStart":461,"sourceCodeEnd":497,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/models/CollectionCommon.py#L461-L497","documentation":"The `limit` parameter of `collection.delete()` must be a Python int (bools are explicitly rejected because bool subclasses int). A TypeError is raised when limit is a float, string, None-like sentinel, or boolean.","triggerScenarios":"`collection.delete(where={...}, limit=10.0)`, `limit=\"10\"`, `limit=True/False`, or limit coming from JSON/config that was not cast to int.","commonSituations":"Loading limit from a config file or API payload where numbers arrive as strings/floats; passing a boolean flag into the wrong keyword argument.","solutions":["Pass a plain int: `collection.delete(where=..., limit=10)`","Coerce external values first: `limit = int(limit)` (after range-checking)","Ensure you are not accidentally passing a bool (e.g. a parsed toggle) as limit"],"exampleFix":"# before\ncollection.delete(where={\"topic\": \"news\"}, limit=\"100\")  # TypeError\n\n# after\ncollection.delete(where={\"topic\": \"news\"}, limit=100)","handlingStrategy":"type-guard","validationCode":"limit = int(limit) if isinstance(limit, (int, float)) and not isinstance(limit, bool) else None","typeGuard":"def is_valid_limit(v) -> bool:\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":null,"preventionTips":["Coerce config/env values to int at load time, not at the call site","Remember bool is an int subclass — never pass flags as limit","Wrap delete calls in a helper that type-checks limit once"],"tags":["limit","type-validation","delete"],"backgroundTag":"invalid-argument-type","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}