{"record":{"id":"16a12175b6b4eb2f","repo":"chroma-core/chroma","slug":"you-must-provide-either-ids-wher","errorCode":null,"errorMessage":"\n                You must provide either ids, where, or where_document to delete. If\n                you want to delete all data in a collection you can delete the\n                collection itself using the delete_collection method. Or alternatively,\n                you can get() all the relevant ids and then delete them.\n                ","messagePattern":"\n                You must provide either ids, where, or where_document to delete\\. If\n                you want to delete all data in a collection you can delete the\n                collection itself using the delete_collection method\\. Or alternatively,\n                you can get\\(\\) all the relevant ids and then delete them\\.\n                ","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/api/segment.py","lineNumber":776,"sourceCode":"        )\n\n        # TODO: Replace with unified validation\n        if where is not None:\n            validate_where(where)\n\n        if where_document is not None:\n            validate_where_document(where_document)\n\n        # You must have at least one of non-empty ids, where, or where_document.\n        if (\n            (ids is None or (ids is not None and len(ids) == 0))\n            and (where is None or (where is not None and len(where) == 0))\n            and (\n                where_document is None\n                or (where_document is not None and len(where_document) == 0)\n            )\n        ):\n            raise ValueError(\n                \"\"\"\n                You must provide either ids, where, or where_document to delete. If\n                you want to delete all data in a collection you can delete the\n                collection itself using the delete_collection method. Or alternatively,\n                you can get() all the relevant ids and then delete them.\n                \"\"\"\n            )\n\n        scan = self._scan(collection_id)\n\n        self._quota_enforcer.enforce(\n            action=Action.DELETE,\n            tenant=tenant,\n            ids=ids,\n            where=where,\n            where_document=where_document,\n        )\n","sourceCodeStart":758,"sourceCodeEnd":794,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/api/segment.py#L758-L794","documentation":"SegmentAPI._delete refuses to run a delete with no criteria: when ids, where and where_document are all None or empty, it raises a ValueError explaining you must pass one of them, delete the collection itself, or get() all ids and delete those. The guard is deliberate — an unfiltered delete would silently wipe every record in the collection.","triggerScenarios":"collection.delete() with no arguments, or with every filter empty: ids=None/[], where=None/{}, where_document=None/{}.","commonSituations":"Expecting SQL-style 'DELETE FROM table' semantics; dynamically built filters that end up empty (e.g. an empty ids list returned by a previous get()); refactors away from explicit id lists.","solutions":["If all records should go, delete and recreate: client.delete_collection(name) then get_or_create_collection","To empty the collection but keep it: ids = coll.get()['ids']; coll.delete(ids=ids)","Guard the call site: refuse to call delete() unless at least one of ids/where/where_document is non-empty"],"exampleFix":"// before\ncoll.delete()  # ValueError: provide ids, where, or where_document\n\n// after\ncoll.delete(ids=coll.get()['ids'])  # explicit delete-all-records","handlingStrategy":"validation","validationCode":"def safe_delete(coll, ids=None, where=None, where_document=None):\n    if not ids and not where and not where_document:\n        raise ValueError('Refusing to delete without ids/where/where_document')\n    return coll.delete(ids=ids, where=where, where_document=where_document)\n\ndef delete_all_records(coll):\n    ids = coll.get()['ids']\n    if ids:\n        coll.delete(ids=ids)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat delete() as requiring criteria by contract; enforce it in your own wrapper","Use delete_collection + recreate for true wipe-all semantics","Never build filter dicts that can silently collapse to empty"],"tags":["chroma","delete","empty-filter","validation","guard-clause"],"backgroundTag":"delete-requires-filter-criteria","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}