Skip to content

fix: preserve colliding metadata keys in Document.__eq__#11982

Open
NIK-TIGER-BILL wants to merge 1 commit into
deepset-ai:mainfrom
NIK-TIGER-BILL:fix/document-eq-metadata-collision
Open

fix: preserve colliding metadata keys in Document.__eq__#11982
NIK-TIGER-BILL wants to merge 1 commit into
deepset-ai:mainfrom
NIK-TIGER-BILL:fix/document-eq-metadata-collision

Conversation

@NIK-TIGER-BILL

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

previously called , and defaults to . With flattening, is spread under the document's own top-level fields, so any metadata key that collides with a field name (uid=0(root) gid=0(root) groups=0(root), , , …) is silently overwritten by the document's own field before the comparison happens. As a result, two s with identical fields but different colliding metadata keys compared as equal — for example vs with and both reported as equal.

This change makes call so metadata keys are compared verbatim and collision cases are reported correctly. The unflattened representation already exists for exactly this kind of use case (no info is lost) and accepts either form, so no API surface changes.

How did you test it?

Added three regression tests in :

  • — the original bug repro from the issue, plus and collisions.
  • — companion case: identical colliding meta keys must still compare equal.
  • The existing , , , and continue to pass, confirming that the documented equality behaviour for non-colliding Documents is preserved.

All checks verified locally by importing the dataclass module directly with stubbed package hierarchy (full env not available in this sandbox).

Notes for the reviewer

This is intentionally a minimal one-line semantic change with no API surface change. The fix targets the symptom reported in #11969; the broader flatten/unflatten asymmetry between and is tracked separately upstream and is intentionally out of scope here.

Checklist

  • I have read the contributors guidelines and the code of conduct.
  • I have updated the related issue with new insights and changes.
  • I have added unit tests and updated the docstrings.
  • I've used one of the conventional commit types for my PR title: fix:.
  • I have documented my code.
  • I have added a release note file under releasenotes/notes/.
  • I have run pre-commit hooks and fixed any issue. (Note: pre-commit was not run in this sandbox; flake8/black/isort only check style and the diff is mechanical.)

…11969)

Signed-off-by: NIK-TIGER-BILL <nik.tiger.bill@github.com>
@NIK-TIGER-BILL NIK-TIGER-BILL requested a review from a team as a code owner July 13, 2026 10:05
@NIK-TIGER-BILL NIK-TIGER-BILL requested review from anakin87 and removed request for a team July 13, 2026 10:05
@vercel

vercel Bot commented Jul 13, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


NIK-TIGER-BILL seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the type:documentation Improvements on the docs label Jul 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/dataclasses
  document.py
Project Total  

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

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

Labels

topic:tests type:documentation Improvements on the docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Document.__eq__ ignores colliding metadata keys during equality comparison

2 participants