Skip to content

Commit dde30a2

Browse files
authored
Give warning instead of error for wrong mongo URI (#2198)
Quick fix for issue #2197 By raising a warning instead of an error optimade should still work. I leave it up to @ml-evs to make a more permanent solution. Removed needless check for self.mongo_database
1 parent 9af05bc commit dde30a2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

optimade/server/config.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,15 +490,17 @@ def align_mongo_uri_and_mongo_database(self) -> "ServerConfig":
490490
491491
"""
492492
if self.database_backend == SupportedBackend.MONGODB:
493-
if self.mongo_uri and self.mongo_database:
493+
if self.mongo_uri:
494494
import pymongo.uri_parser
495495

496496
if not self.mongo_uri.startswith(
497497
"mongodb://"
498498
) or self.mongo_uri.startswith("mongodb+srv://"):
499499
self.mongo_uri = f"mongodb://{self.mongo_uri}"
500500

501-
uri: dict[str, Any] = pymongo.uri_parser.parse_uri(self.mongo_uri)
501+
uri: dict[str, Any] = pymongo.uri_parser.parse_uri(
502+
self.mongo_uri, warn=True
503+
)
502504
if uri.get("database"):
503505
self.mongo_database = uri["database"]
504506

0 commit comments

Comments
 (0)