Skip to content

The agent engineering platform.

LangChain-Community - AzureCosmos Mongo vCore: Bug Fix when the data doesn't contain metadata field (#27772)

Aayush Katariaa8a33b2dc650
diff --git a/libs/community/langchain_community/vectorstores/azure_cosmos_db.py b/libs/community/langchain_community/vectorstores/azure_cosmos_db.py
index 92a450bd86..0db46922a6 100644
--- a/libs/community/langchain_community/vectorstores/azure_cosmos_db.py
+++ b/libs/community/langchain_community/vectorstores/azure_cosmos_db.py
@@ -460,7 +460,7 @@ class AzureCosmosDBVectorSearch(VectorStore):
continue
document_object_field = res.pop("document")
text = document_object_field.pop(self._text_key)
- metadata = document_object_field.pop("metadata")
+ metadata = document_object_field.pop("metadata", {})
if with_embedding:
metadata[self._embedding_key] = document_object_field.pop(
self._embedding_key