From 7d1e2c316407b86c088e3c0ffa711ee465012bcb Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Thu, 13 Aug 2026 14:09:10 -0700 Subject: [PATCH] Cheap defensive stuff but I'm not going to try and cover a malformed row everywhere --- src/paperless_ai/indexing.py | 8 ++++++-- src/paperless_ai/taxonomy.py | 5 ++++- 2 files changed, 10 insertions(+), 3 deletions(-) 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)