chroma-core / chroma-core/chroma
[BUG](api): warnings.warn() missing stacklevel=2 in 32 call sites
- Dominant language
- Rust
- Stars
- 29.3k
- Forks
- 2.5k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 38
Description
## Problem
32 `warnings.warn()` calls across the codebase are missing the `stacklevel=2` parameter. Without it, warnings point to library internals (e.g., `chromadb/utils/embedding_functions/huggingface_embedding_function.py:38`) instead of the user code that triggered them.
This makes debugging harder for users — they see a warning pointing at Chroma internals instead of the actual call site in their own code.
## Affected Files
- `chromadb/utils/embedding_functions/` — 14 files (all embedding function `__init__` methods)
- `chromadb/api/types.py` — 7 call sites
- `chromadb/api/collection_configuration.py` — 7 call sites
- `chromadb/utils/embedding_functions/bm25_embedding_function.py` — 1 call site
- `chromadb/utils/embedding_functions/google_embedding_function.py` — 3 call sites (line 246, 396, 524)
## Proposed Fix
Add `stacklevel=2` to all 32 affected `warnings.warn()` calls. All are inside `__init__` methods or class methods where the warning should point to the caller (user code) rather than the library internals.
## Detection
```bash
grep -rn "warnings\.warn(" --include="*.py" chromadb/ | grep -v stacklevel | grep -v test
```
This returns 32 hits across the codebase.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the listed files under chromadb/utils/embedding_functions/, chromadb/api/types.py, and chromadb/api/collection_configuration.py, then run the provided grep command to review all 32 call sites. Add the specified argument to each affected warning and rerun the grep check; done means no non-test warnings.warn() calls remain without it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 76/100