Skip to content

Commit fa8e31f

Browse files
Merge pull request #147 from blacklanternsecurity/fix-bad-mongo-uri-parsing
Fix bad mongo URI parsing
2 parents a1273ba + 76cd5d2 commit fa8e31f

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

bbot_server/modules/server/server_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
from subprocess import run
77
from contextlib import suppress
88

9+
from pymongo import uri_parser
10+
911
from bbot_server.config import BBOT_SERVER_CONFIG as bbcfg, BBOT_SERVER_DIR
1012
from bbot_server.cli.base import BaseBBCTL, subcommand, Option, Annotated
1113

@@ -158,7 +160,7 @@ def cleardb(
158160
)
159161

160162
for store_name, store_config, data_desc in stores_to_clear:
161-
db_name = store_config.uri.split("/")[-1]
163+
db_name = uri_parser.parse_uri(store_config.uri)["database"]
162164
prefix = store_config.collection_prefix
163165
if not db_name:
164166
raise self.BBOTServerError(f"{store_name.title()} database not found in config")

bbot_server/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class BaseMongoStore(BaseDB):
88
async def setup(self):
99
self.client = AsyncMongoClient(self.uri)
10-
self.db = self.client.get_database(self.db_name)
10+
self.db = self.client.get_default_database()
1111
self.collection_prefix = getattr(self.db_config, "collection_prefix", "")
1212
bucket_name = f"{self.collection_prefix}fs" if self.collection_prefix else "fs"
1313
self.fs = AsyncGridFSBucket(self.db, bucket_name=bucket_name)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "bbot-server"
3-
version = "0.1.3"
3+
version = "0.1.4"
44
description = ""
55
authors = [{name = "TheTechromancer"}]
66
license = "AGPL-3.0"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)