chroma-core/chroma · error · ValueError
You must provide either ids, where, or wher
Error message
You must provide either ids, where, or where_document to delete. If
you want to delete all data in a collection you can delete the
collection itself using the delete_collection method. Or alternatively,
you can get() all the relevant ids and then delete them.
What it means
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.
Source
Thrown at chromadb/api/segment.py:776
)
# TODO: Replace with unified validation
if where is not None:
validate_where(where)
if where_document is not None:
validate_where_document(where_document)
# You must have at least one of non-empty ids, where, or where_document.
if (
(ids is None or (ids is not None and len(ids) == 0))
and (where is None or (where is not None and len(where) == 0))
and (
where_document is None
or (where_document is not None and len(where_document) == 0)
)
):
raise ValueError(
"""
You must provide either ids, where, or where_document to delete. If
you want to delete all data in a collection you can delete the
collection itself using the delete_collection method. Or alternatively,
you can get() all the relevant ids and then delete them.
"""
)
scan = self._scan(collection_id)
self._quota_enforcer.enforce(
action=Action.DELETE,
tenant=tenant,
ids=ids,
where=where,
where_document=where_document,
)
View on GitHub (pinned to aecdd12c8a)
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
Example fix
// before coll.delete() # ValueError: provide ids, where, or where_document // after coll.delete(ids=coll.get()['ids']) # explicit delete-all-records
Defensive patterns
Strategy: validation
Validate before calling
def safe_delete(coll, ids=None, where=None, where_document=None):
if not ids and not where and not where_document:
raise ValueError('Refusing to delete without ids/where/where_document')
return coll.delete(ids=ids, where=where, where_document=where_document)
def delete_all_records(coll):
ids = coll.get()['ids']
if ids:
coll.delete(ids=ids) Prevention
- 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
When it happens
Trigger: collection.delete() with no arguments, or with every filter empty: ids=None/[], where=None/{}, where_document=None/{}.
Common situations: 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.
Related errors
- MinK keys cannot be empty
- MaxK keys cannot be empty
- GroupBy keys cannot be empty
- GroupBy requires 'keys' array
- GroupBy requires 'aggregate'
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/16a12175b6b4eb2f.
Report an issue: GitHub.