Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

fix: filter None chunk results in graph merge_batch_data

dex0shubhamac9225ee8ae4
diff --git a/hyperextract/types/graph.py b/hyperextract/types/graph.py
index 97ce1c3..1878076 100644
--- a/hyperextract/types/graph.py
+++ b/hyperextract/types/graph.py
@@ -692,6 +692,13 @@ class AutoGraph(
logger.warning("stage=merge_batch_empty input_is_empty")
return self.graph_schema(nodes=[], edges=[])
+ # Drop failed (None) chunk results from the list form; otherwise a single
+ # failed invoke() ([None]) falls through to the tuple branch and asserts.
+ if isinstance(data_list_or_tuple, list):
+ data_list_or_tuple = [g for g in data_list_or_tuple if g is not None]
+ if not data_list_or_tuple:
+ return self.graph_schema(nodes=[], edges=[])
+
logger.debug(
"stage=merge_batch_start input_type=%s",
"tuple"
diff --git a/hyperextract/types/hypergraph.py b/hyperextract/types/hypergraph.py
index a3fb046..d4bfe22 100644
--- a/hyperextract/types/hypergraph.py
+++ b/hyperextract/types/hypergraph.py
@@ -613,6 +613,13 @@ class AutoHypergraph(
logger.warning("stage=merge_batch_empty input_is_empty")
return self.graph_schema(nodes=[], edges=[])
+ # Drop failed (None) chunk results from the list form; otherwise a single
+ # failed invoke() ([None]) falls through to the tuple branch and asserts.
+ if isinstance(data_list_or_tuple, list):
+ data_list_or_tuple = [g for g in data_list_or_tuple if g is not None]
+ if not data_list_or_tuple:
+ return self.graph_schema(nodes=[], edges=[])
+
if isinstance(data_list_or_tuple, list) and isinstance(
data_list_or_tuple[0], self.graph_schema
):