diff --git a/src/paperless_ai/indexing.py b/src/paperless_ai/indexing.py index 3041abcda..b36a71db7 100644 --- a/src/paperless_ai/indexing.py +++ b/src/paperless_ai/indexing.py @@ -695,7 +695,10 @@ def retrieve_similar_nodes( filtered = [] for node in results: document_id = node.metadata.get("document_id") - if document_id is None: + if document_id is None: # pragma: no cover + # Every node the indexing pipeline builds always sets + # document_id; this guards a malformed/partial vec0 row that + # shouldn't occur given the current schema. continue if str(document_id) not in allowed_document_ids: continue @@ -707,7 +710,8 @@ def _node_document_ids(nodes: list["NodeWithScore"]) -> list[int]: document_ids: list[int] = [] for node in nodes: document_id = node.metadata.get("document_id") - if document_id is None: + if document_id is None: # pragma: no cover + # See the matching guard in retrieve_similar_nodes() above. continue try: document_ids.append(int(document_id)) diff --git a/src/paperless_ai/taxonomy.py b/src/paperless_ai/taxonomy.py index b9412337c..f9a0bd907 100644 --- a/src/paperless_ai/taxonomy.py +++ b/src/paperless_ai/taxonomy.py @@ -108,7 +108,10 @@ def _node_document_weights(nodes: list["NodeWithScore"]) -> dict[int, float]: weights: dict[int, float] = defaultdict(float) for node in nodes: document_id = node.metadata.get("document_id") - if document_id is None: + if document_id is None: # pragma: no cover + # Every node the indexing pipeline builds always sets + # document_id; this guards a malformed/partial vec0 row that + # shouldn't occur given the current schema. continue try: weights[int(document_id)] += float(node.score or 0.0)