Skip to content

Commit 5f1489b

Browse files
ezimuelCopilot
andauthored
Update src/VectorDatabase.php
Add return value check on document delete Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4d1b4cd commit 5f1489b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/VectorDatabase.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,12 @@ public function deleteDocument(string|int $id): bool
188188
$nodeId = $this->docIdToNodeId[$id];
189189

190190
// Soft-delete from HNSW (node stays for connectivity, excluded from results).
191-
$this->hnswIndex->delete($nodeId);
191+
$deletedFromHnsw = $this->hnswIndex->delete($nodeId);
192+
if ($deletedFromHnsw !== true) {
193+
throw new \RuntimeException(
194+
sprintf('Failed to delete node "%s" from HNSW index.', (string) $nodeId)
195+
);
196+
}
192197

193198
// Fully remove from BM25.
194199
$this->bm25Index->removeDocument($nodeId);

0 commit comments

Comments
 (0)