Skip to content

fix: hydrate references correctly across nested EmbeddedDocumentListFields - #10

Merged
arunsureshkumar merged 1 commit into
feat/asyncfrom
fix/nested-embedded-list-reference-hydrate
Sep 20, 2026
Merged

arunsureshkumar merged 1 commit into
feat/asyncfrom
fix/nested-embedded-list-reference-hydrate

Conversation

@harikrishnang33

Copy link
Copy Markdown

Summary

  • A ReferenceField nested two EmbeddedDocumentListFields deep (e.g. integrations[].brands[].brand) crashed MongoDB with $mergeObjects requires object inputs, but input [...] is of type array, because the hydrate stage flattened the dotted path crossing both array levels into a single $map, handing MongoDB an array-of-arrays.
  • Threads a list_chain (per-array-level relative segments) alongside the existing embedded_list_path through _walk_lookups, and builds nested $map/$mergeObjects stages matching the real document shape via a new _build_nested_list_hydrate_expr helper, shared by both the structured-ref and generic-ref embedded-list lookups.

Test plan

  • uv run pytest tests/test_pipeline_builder.py -q — 8/8 passed, including a new regression test (test_doubly_nested_embedded_list_reference_hydrate) reproducing the exact integrations[].brands[].brand shape
  • ruff check / ruff format --check — no new issues introduced

…ields

A ReferenceField nested two EmbeddedDocumentListFields deep (e.g.
integrations[].brands[].brand) crashed MongoDB with "$mergeObjects requires
object inputs, but input [...] is of type array". The hydrate stage
flattened the dotted path crossing both array levels into a single $map,
so MongoDB handed it an array-of-arrays instead of a flat list of items.

Thread a list_chain (per-array-level relative segments) alongside the
existing embedded_list_path through _walk_lookups, and build nested
$map/$mergeObjects stages matching the real document shape via a new
_build_nested_list_hydrate_expr helper, shared by both the structured-ref
and generic-ref embedded-list lookups.
@arunsureshkumar
arunsureshkumar merged commit 1e73332 into feat/async Sep 20, 2026
248 checks passed
@harikrishnang33
harikrishnang33 deleted the fix/nested-embedded-list-reference-hydrate branch September 21, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants