Skip to content

fix: filter None chunk results in graph merge_batch_data - #69

Merged
yifanfeng97 merged 2 commits into
yifanfeng97:mainfrom
dex0shubham:fix/merge-batch-none-list
Aug 12, 2026
Merged

fix: filter None chunk results in graph merge_batch_data#69
yifanfeng97 merged 2 commits into
yifanfeng97:mainfrom
dex0shubham:fix/merge-batch-none-list

Conversation

@dex0shubham

Copy link
Copy Markdown
Contributor

Problem

In one-stage extraction, the single-chunk path does:

graph = self.data_extractor.invoke(inp)
graph_list = [graph]
... merge_batch_data(graph_list)

with_structured_output(method="function_calling") can return None when the model emits no tool call. merge_batch_data([None]) then falls through to the tuple branch and hits assert len(data_list_or_tuple) == 2, raising AssertionError instead of degrading gracefully. (The multi-chunk batch path already filters None via _filter_none_results; the single-chunk path did not.)

This affects AutoGraph, AutoHypergraph, and the three specialized graphs (AutoTemporalGraph, AutoSpatialGraph, AutoSpatioTemporalGraph), which all inherit merge_batch_data.

Fix

Filter None entries from the list form at the top of merge_batch_data (in graph.py and hypergraph.py — the only two definitions). An all-None list returns an empty graph. The tuple form ((nodes_lists, edges_lists)) is a tuple, not a list, so it's unaffected. Fixing this one chokepoint covers all five graph types.

Tests

merge_batch_data([None]) returns an empty graph/hypergraph instead of raising, for both AutoGraph and AutoHypergraph. Both fail with AssertionError on the pre-fix code.

ruff check/ruff format --check on hyperextract clean.

@yifanfeng97
yifanfeng97 merged commit ecba6c5 into yifanfeng97:main Aug 12, 2026
4 checks passed
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