Skip to content

fix: accept zero hierarchy meta values in AutoMergingRetriever - #12635

Merged
sjrl merged 1 commit into
deepset-ai:mainfrom
coder058:fix/automerge-falsy-hierarchy-meta
Sep 7, 2026
Merged

fix: accept zero hierarchy meta values in AutoMergingRetriever#12635
sjrl merged 1 commit into
deepset-ai:mainfrom
coder058:fix/automerge-falsy-hierarchy-meta

Conversation

@coder058

@coder058 coder058 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Related Issues

Proposed Changes:

AutoMergingRetriever._check_valid_documents validated __level and __block_size with truthiness (doc.meta.get(...)), so a present value of 0 was treated as missing.

HierarchicalDocumentSplitter intentionally stores __level=0 and __block_size=0 on the root document. Validation now checks key presence (__level in doc.meta) instead of truthiness. __parent_id` still requires a truthy value because leaves must point at a parent.

How did you test it?

  • Added test_run_accepts_zero_level_and_block_size.
  • Confirmed the new test fails on unmodified main without this patch (ValueError: ... '__level').
  • Confirmed the new test passes with the patch.
  • Ran the full AutoMergingRetriever unit suite: hatch -e test run pytest test/components/retrievers/test_auto_merging_retriever.py → 20 passed.

Notes for the reviewer

Checklist

This PR was fully generated with an AI assistant. I have reviewed the changes and run the relevant tests.

HierarchicalDocumentSplitter stores __level=0 and __block_size=0 on the
root. Validation must check key presence, not truthiness.
@coder058
coder058 requested a review from a team as a code owner September 6, 2026 20:34
@coder058
coder058 requested review from sjrl and removed request for a team September 6, 2026 20:34
@vercel

vercel Bot commented Sep 6, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Sep 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sjrl sjrl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  haystack/components/retrievers
  auto_merging_retriever.py
  filter_retriever.py
Project Total  

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

@sjrl
sjrl merged commit d8ad629 into deepset-ai:main Sep 7, 2026
25 of 26 checks passed
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.

AutoMergingRetriever treats __level=0 / __block_size=0 as missing metadata

3 participants