Skip to content

armgit / mem0

Public Imported from GitHub
0

The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.

fix: only list authorized collections when listing MongoDB collections (#3888)

Noah Stapp215d8b5a71ff
diff --git a/mem0/vector_stores/mongodb.py b/mem0/vector_stores/mongodb.py
index b9cf0aa6b..5fae0ff36 100644
--- a/mem0/vector_stores/mongodb.py
+++ b/mem0/vector_stores/mongodb.py
@@ -51,7 +51,7 @@ class MongoDB(VectorStoreBase):
"""Create new collection with vector search index."""
try:
database = self.client[self.db_name]
- collection_names = database.list_collection_names()
+ collection_names = database.list_collection_names(authorizedCollections=True)
if self.collection_name not in collection_names:
logger.info(f"Collection '{self.collection_name}' does not exist. Creating it now.")
collection = database[self.collection_name]
@@ -240,7 +240,7 @@ class MongoDB(VectorStoreBase):
List[str]: List of collection names.
"""
try:
- collections = self.db.list_collection_names()
+ collections = self.db.list_collection_names(authorizedCollections=True)
logger.info(f"Listing collections in database '{self.db_name}': {collections}")
return collections
except PyMongoError as e: