[BUG]: Drop pydantic v1 compatibility layer for Python 3.14 support#6356
[BUG]: Drop pydantic v1 compatibility layer for Python 3.14 support#6356HammadB merged 3 commits intochroma-core:mainfrom
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
5d8e026 to
7c2b8ab
Compare
Patch pydantic at runtime so chromadb's broken pydantic v1 usage works on 3.14. Remove once chromadb ships a fix (chroma-core/chroma#6356).
Patch pydantic at runtime so chromadb's broken pydantic v1 usage works on 3.14. Remove once chromadb ships a fix (chroma-core/chroma#6356).
|
@basnijholt - thank you! Maintainers: Would be great if you could merge this important fix! :-) The v2 for Pydantic and also Pydantic-settings was released in June 2023, hopefully an acceptable version bump for you. |
|
@HammadB, just to make it obvious–currently at least 1000 downstream dependencies of ChromaDB cannot support Python 3.14 because this simple problem. In my own library that uses ChromaDB, I have to jump through insane runtime monkeypatching to get it to work (basnijholt/agent-cli@6f868f5). I am confident that almost all developers would value supporting new Python versions over backward compatibility with pydantic v1. |
|
9 out of 10 major chromadb dependents already require pydantic v2 (directly or transitively), so the v1 compat layer serves essentially no one:
The only holdout is Reproduce with this script"""Check whether major chromadb dependents already require pydantic v2."""
import json, re, urllib.request
def get_requires_dist(pkg):
try:
url = f"https://pypi.org/pypi/{pkg}/json"
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=10) as resp:
data = json.loads(resp.read())
return data.get("info", {}).get("requires_dist") or []
except Exception:
return []
def find_pydantic_v2_req(pkg, depth=0, visited=None):
if visited is None:
visited = set()
if pkg in visited or depth > 2:
return None
visited.add(pkg)
for dep in get_requires_dist(pkg):
dep_clean = re.split(r"\s*;", dep)[0].strip()
dep_name = re.split(r"[\s>=<\[!]", dep_clean)[0].lower()
if dep_name == "pydantic" and re.search(r">=\s*2", dep):
return (pkg if depth > 0 else "direct", dep_clean)
if depth < 1 and dep_name not in visited:
result = find_pydantic_v2_req(dep_name, depth + 1, visited)
if result:
return result
return None
for pkg in [
"langchain-chroma", "llama-index-vector-stores-chroma",
"crewai", "embedchain", "semantic-kernel", "mem0ai",
"superagi", "llmware", "langflow", "chromadb-client",
]:
result = find_pydantic_v2_req(pkg)
if result:
via, constraint = result
print(f"{pkg}: requires pydantic v2 (via {via}) — {constraint}")
else:
print(f"{pkg}: does NOT require pydantic v2") |
VectorStore now operates as a silent no-op when ChromaDB cannot be imported (pydantic-v1 incompatibility on Python 3.14). SQLite memory and all other features continue working; only semantic vector search is disabled until ChromaDB ships a fix (PR chroma-core/chroma#6356). Simplified test skip logic to import HAS_CHROMADB from the module. Memory-tools tests no longer skip since they only use mocks. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
+1 |
1 similar comment
|
+1 |
ChromaDB depends on pydantic v1 which raises a ConfigError on Python 3.14 due to removed internal CPython APIs. This breaks the MCP server on import (state_manager.py line 13). Changes: - Wrap chromadb import in try/except; export HAS_CHROMADB flag - Guard get_chroma_client, get_chat_collection, get_session_summary_collection with early None returns - search_archived_summaries returns a helpful no-op message - save_chat_snapshot skips ChromaDB sync when unavailable - Log a warning at startup when vector search is disabled - Move chromadb from required to optional dependency (pip install deesim[vector]) All non-vector functionality (file-based chat history, SQLite inventory/quests, dice, rules lookup, etc.) continues to work. Ref: chroma-core/chroma#6356 Co-Authored-By: Claude Opus 4.6 <[email protected]>
7c2b8ab to
bfb26eb
Compare
|
This also updates dependency constraints across server and client packaging to require pydantic v2 and pydantic-settings. Possible Issues• Any downstream code relying on This summary was automatically generated by @propel-code-bot |
671a28a to
b80822d
Compare
|
@kylediaz I pushed a follow-up fix for the remaining Python 3.14 test failure in this PR ( I fixed I verified locally with:
This should unblock the 3.14 cross-version CI path from our side. Is there anything else you want me to do to get this merged? |
808c452 to
bef3358
Compare
|
Hey @basnijholt |
|
Great! You only lost this commit on the force push 808c452. |
|
your PR was good as-is. It will fail if we add python 3.14, but that is not because of your code, it's because of how |
|
@basnijholt thanks! we're going to make a release for this fix ASAP |
`pydantic_settings.BaseSettings` defaults to `extra="forbid"`, which means any environment variable or `.env` key that doesn't match a `Settings` field raises a `ValidationError` at import time. This is a follow-up to chroma-core#6356 which switched from pydantic v1 `BaseSettings` to pydantic-settings v2. The old v1 `BaseSettings` silently ignored unrecognized env vars, but v2 rejects them by default. Adding `"extra": "ignore"` restores the previous tolerance so users with unrelated env vars (e.g. `OPENAI_API_KEY`, `GEMINI_API_KEY`) in their environment or `.env` file can import chromadb without errors.
Fixes #5996 — chromadb crashes on import with Python 3.14 because
pydantic.v1compat layer breaks on 3.14.The rest of the codebase already uses pydantic v2 APIs, so this just drops the v1 shim in
config.py:pydantic_settings.BaseSettings+pydantic.field_validatordirectlychroma_coordinator_host,chroma_logservice_host,chroma_logservice_port) — required by pydantic v2class Config→model_configdictpydantic >= 2.0, addpydantic-settings >= 2.0There's a larger PR in #5842 that also cleans up
fastapi/__init__.pyandtypes.py, but those files already work fine — this is just the minimum to unbreak 3.14.Tested on Python 3.14.1: import works,
test_config.pypasses,PersistentClientround-trips documents.