From a53c2a8c6b362f20a944ddb9e5a34a9fd97b3b44 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 12 Aug 2024 08:52:16 -0600 Subject: [PATCH 1/2] fix: Pass all parsed options to ReconnectingPostgresqlDatabase --- backend/apps/webui/internal/wrappers.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/backend/apps/webui/internal/wrappers.py b/backend/apps/webui/internal/wrappers.py index 2b5551ce2..cab081b78 100644 --- a/backend/apps/webui/internal/wrappers.py +++ b/backend/apps/webui/internal/wrappers.py @@ -54,13 +54,7 @@ def register_connection(db_url): connection = parse(db_url) # Use our custom database class that supports reconnection - db = ReconnectingPostgresqlDatabase( - connection["database"], - user=connection["user"], - password=connection["password"], - host=connection["host"], - port=connection["port"], - ) + db = ReconnectingPostgresqlDatabase(**connection) db.connect(reuse_if_open=True) elif isinstance(db, SqliteDatabase): # Enable autoconnect for SQLite databases, managed by Peewee From e63d5778a864d5a3118244b85c347877acc06890 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Mon, 12 Aug 2024 08:52:16 -0600 Subject: [PATCH 2/2] fix: Decode URL-encoded characters in passwords This enables using passwords containing special characters. --- backend/apps/webui/internal/wrappers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/apps/webui/internal/wrappers.py b/backend/apps/webui/internal/wrappers.py index cab081b78..cc4a42421 100644 --- a/backend/apps/webui/internal/wrappers.py +++ b/backend/apps/webui/internal/wrappers.py @@ -43,7 +43,7 @@ class ReconnectingPostgresqlDatabase(CustomReconnectMixin, PostgresqlDatabase): def register_connection(db_url): - db = connect(db_url) + db = connect(db_url, unquote_password=True) if isinstance(db, PostgresqlDatabase): # Enable autoconnect for SQLite databases, managed by Peewee db.autoconnect = True @@ -51,7 +51,7 @@ def register_connection(db_url): log.info("Connected to PostgreSQL database") # Get the connection details - connection = parse(db_url) + connection = parse(db_url, unquote_password=True) # Use our custom database class that supports reconnection db = ReconnectingPostgresqlDatabase(**connection)