## TL;DR
`get_collection` throws InvalidCollectionException because no collection with that name exists in the ChromaDB instance you connected to. Fix it by creating the collection first (or using get_or_create_collection), and double-check the persist path and client mode so you arent talking to a fresh empty database.

```text
chromadb InvalidCollectionException: collection does not exist
```

## Use this when
- `client.get_collection("name")` raises InvalidCollectionException
- An agent queries a collection it never created
- The error appears after changing persist directories or client modes

## Not for this skill when
- The collection exists but inserts fail on dimensions (thats an embedding mismatch)
- The client cant connect at all (thats the server or path)
- Persistence files look corrupted (thats a recovery job)

## Steps

1. List what actually exists in the instance you connected to:

```python
print([c.name for c in client.list_collections()])
```
Expected output: the real collection names. If your name isnt there, the bug is confirmed; check for typos and case differences.

2. Create it if it should exist, or switch to get-or-create:

```python
collection = client.get_or_create_collection("docs")
```
Expected output: no exception. `get_collection` is strict by design; `get_or_create_collection` is what most pipelines actually want.

3. Verify the persist path. A common trap is creating the collection under one path and reading from another:

```python
import chromadb
client = chromadb.PersistentClient(path="/data/chroma")
print([c.name for c in client.list_collections()])
```
Expected output: the collections you expect. If the list is empty, the path is wrong or the data was written by an in-memory client that never persisted.

4. Check client mode consistency: an HttpClient and a PersistentClient are separate stores that share nothing:

```python
# pick ONE mode everywhere in the pipeline
```
Expected output: all pipeline stages use the same client construction. Mixing modes is the same as using two different databases.

## Variant phrasings

### collection exists in one script but not another
The two scripts use different persist paths or different client modes. Print the path in both.

### worked yesterday, gone today
The persist directory was wiped (ephemeral container storage) or the path is relative and the working dir changed. Use absolute paths.

## Why it happens
ChromaDB collections live inside a specific database instance (a path, a server, or memory). `get_collection` does a strict lookup and throws when the name is absent, which happens through typos, wrong paths, mixed client modes, or simply querying before any write. Agents hit it because they generate the query code and the ingest code in separate steps that disagree on the name or path.

## Edge cases
- Collection names are case-sensitive; "Docs" and "docs" are different collections.
- Deleting the persist directory while a client holds it open produces confusing states; restart the client after filesystem changes.
- In client/server mode, the server's data dir is what matters, not the client's local path.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_ItI7uXjP539VVDKjU0Mjtw
