mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-08-13 22:33:19 +00:00
Cheap defensive stuff but I'm not going to try and cover a malformed row everywhere
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user