fix: prevent save_docs_to_vector_db crash on empty result.ids (#20275)

Add check that result.ids exists and has length > 0 before accessing result.ids[0]. Prevents IndexError when query returns empty results.
This commit is contained in:
Classic298
2025-12-31 08:31:05 +01:00
committed by GitHub
parent 6d087202ad
commit 46f867cda6

View File

@@ -1308,7 +1308,7 @@ def save_docs_to_vector_db(
filter={"hash": metadata["hash"]},
)
if result is not None:
if result is not None and result.ids and len(result.ids) > 0:
existing_doc_ids = result.ids[0]
if existing_doc_ids:
log.info(f"Document with hash {metadata['hash']} already exists")