fix(chroma): distinguish metadata ID filters from document IDs by CHX606 · Pull Request #4124 · deepset-ai/haystack-core-integrations · GitHub
Skip to content

fix(chroma): distinguish metadata ID filters from document IDs - #4124

Open
CHX606 wants to merge 2 commits into
deepset-ai:mainfrom
CHX606:contrib-chroma-metadata-id-filter
Open

CHX606 wants to merge 2 commits into
deepset-ai:mainfrom
CHX606:contrib-chroma-metadata-id-filter

Conversation

@CHX606

@CHX606 CHX606 commented Oct 18, 2026 •

Copy link
Copy Markdown

Proposed Changes

Chroma metadata can contain an id key independently of Document.id. A top-level filter on meta.id currently loses its namespace during conversion and is then sent as Chroma's document IDs parameter

This can return the wrong document. Given document-a with meta.id="target", and a different document whose Document.id is "target" but meta.id="other", filtering meta.id == "target" currently returns the second document. Wrapping that same metadata condition in AND happens to return the first document

Only the original, unprefixed id field now uses the IDs parameter. meta.id remains a metadata comparison, so equality, inequality and membership retain their metadata semantics. Existing validation is extracted into a small helper without changing it

Reproduction

from haystack import Document
from haystack_integrations.document_stores.chroma import ChromaDocumentStore

store = ChromaDocumentStore(client_settings={"anonymized_telemetry": False})
store.write_documents([
    Document(id="document-a", content="A", meta={"id": "target"}, embedding=[1.0, 0.0]),
    Document(id="target", content="B", meta={"id": "other"}, embedding=[0.0, 1.0]),
])
result = store.filter_documents({"field": "meta.id", "operator": "==", "value": "target"})
print([document.id for document in result])
store.close()

Before, this prints ["target"]. After, it prints ["document-a"]. Filtering the unprefixed id == "target" still returns ["target"]

This uses a real in-memory Chroma collection and supplied embeddings, with no model download, API key or mocked document-store result

How did you test it?

The 13 added regressions give 9 failures and 4 passes on the base, then all pass with the fix. They cover metadata equality, inequality, in/not in, empty-string metadata, no match, a logical AND, and a separate Document.id control

Two additional boundary cases exercise real Chroma validation for a scalar membership value and a non-string content value. They verify the integration's filter exception, metadata/content category, and original ValueError cause without mocking the validator or matching Chroma's full error message

  • hatch run fmt-check passes, including all 16 Chroma package files
  • hatch run test:types passes for all 7 source files
  • The full Chroma unit suite passes with 68 passed and 152 integration cases deselected by marker
  • The existing real in-memory filtering matrix passes with 40 passed and 10 pre-existing null/date limitation skips
  • git diff --check passes

The HTTP-server asynchronous integration suite was not run locally. No dependencies, public parameters, version files or generated changelogs were changed

Notes for the reviewer

AI tooling generated the implementation and regression tests. The patch was checked independently against the original conversion logic and the real Chroma results above. No personal human review is claimed

Checklist

@CHX606
CHX606 requested a review from a team as a code owner October 18, 2026 02:56
@CHX606
CHX606 requested review from bogdankostic and removed request for a team October 18, 2026 02:56
@CLAassistant

CLAassistant commented Oct 18, 2026 •

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage report (chroma)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  integrations/chroma/src/haystack_integrations/document_stores/chroma
  document_store.py
  filters.py
Project Total  

This report was generated by python-coverage-comment-action

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @CHX606, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from bogdankostic October 18, 2026 04:31
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Oct 18, 2026
@HaystackBot
HaystackBot marked this pull request as draft October 18, 2026 04:31
@CHX606
CHX606 marked this pull request as ready for review October 19, 2026 13:01
@HaystackBot HaystackBot removed the cla-pending PR is in draft until the contributor signs the CLA label Oct 19, 2026
@HaystackBot

Copy link
Copy Markdown
Contributor

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants