diff --git a/optimade/server/config.py b/optimade/server/config.py index 6a360577d..4558bea5e 100644 --- a/optimade/server/config.py +++ b/optimade/server/config.py @@ -498,16 +498,11 @@ def align_mongo_uri_and_mongo_database(self) -> "ServerConfig": or self.mongo_uri.startswith("mongodb+srv://") ): self.mongo_uri = f"mongodb://{self.mongo_uri}" - try: - uri: dict[str, Any] = pymongo.uri_parser.parse_uri( - self.mongo_uri, warn=True - ) - if uri.get("database"): - self.mongo_database = uri["database"] - except pymongo.errors.InvalidURI as error_msg: - warnings.warn( - f"The uri {self.mongo_uri} may be invalid.\n{error_msg}" - ) + uri: dict[str, Any] = pymongo.uri_parser.parse_uri( + self.mongo_uri, warn=True + ) + if uri.get("database"): + self.mongo_database = uri["database"] return self