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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user