chroma-core/chroma · error · ValueError

Collection {name} does not exist.

Error message

Collection {name} does not exist.

What it means

SegmentAPI.delete_collection resolves the collection by name in the system database before removing its segments and metadata; when nothing matches that name in the given tenant/database, it raises ValueError('Collection {name} does not exist.'). This is embedded mode's plain-ValueError form of a not-found delete; over HTTP the same situation surfaces as a typed 404 NotFoundError.

Source

Thrown at chromadb/api/segment.py:505

    @override
    @rate_limit
    def delete_collection(
        self,
        name: str,
        tenant: str = DEFAULT_TENANT,
        database: str = DEFAULT_DATABASE,
    ) -> None:
        existing = self._sysdb.get_collections(
            name=name, tenant=tenant, database=database
        )

        if existing:
            self._manager.delete_segments(existing[0].id)
            self._sysdb.delete_collection(
                existing[0].id, tenant=tenant, database=database
            )
        else:
            raise ValueError(f"Collection {name} does not exist.")

    @trace_method("SegmentAPI._add", OpenTelemetryGranularity.OPERATION)
    @override
    @rate_limit
    def _add(
        self,
        ids: IDs,
        collection_id: UUID,
        embeddings: Embeddings,
        metadatas: Optional[Metadatas] = None,
        documents: Optional[Documents] = None,
        uris: Optional[URIs] = None,
        tenant: str = DEFAULT_TENANT,
        database: str = DEFAULT_DATABASE,
    ) -> bool:
        coll = self._get_collection(collection_id)
        self._manager.hint_use_collection(collection_id, t.Operation.ADD)
        validate_batch(

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Check existence first with client.list_collections() and only delete when present
  2. Catch the ValueError and treat 'does not exist' as success when the delete is meant to be idempotent
  3. Verify tenant/database (and persist path) match where the collection was created

Example fix

// before
client.delete_collection('docs')  # ValueError if missing

// after
names = [c.name for c in client.list_collections()]
if 'docs' in names:
    client.delete_collection('docs')
Defensive patterns

Strategy: validation

Validate before calling

def collection_exists(client, name: str, tenant=None, database=None) -> bool:
    return any(c.name == name for c in client.list_collections())

def delete_collection_idempotent(client, name: str) -> None:
    if collection_exists(client, name):
        client.delete_collection(name)

Try / catch

try:
    client.delete_collection('docs')
except ValueError as e:
    if 'does not exist' not in str(e):
        raise  # a different ValueError — re-raise

Prevention

When it happens

Trigger: client.delete_collection('name') where no collection with that name exists in the tenant/database — double deletes, deleting after another client/process already removed it, or a misspelled name.

Common situations: Idempotent startup/teardown code that deletes a known collection; test cleanup running twice; being connected to a different persist directory, tenant or database than where the collection lives; name casing or whitespace mismatches.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/22656323a068ef66. Report an issue: GitHub.