Skip to content

Commit 573c464

Browse files
committed
fix(tools_db): refine user and password retrieval logic for database authentication
1 parent 13e257f commit 573c464

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tools_db.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def is_db_auth_error(error) -> bool:
8383
"authentication failed",
8484
"peer authentication failed",
8585
"auth failed",
86+
"sasl authentication requires a password",
87+
"authentication requires a password",
8688
)
8789
return any(m in text for m in markers)
8890

@@ -99,8 +101,8 @@ def ensure_service_auth(credentials):
99101

100102
service = credentials["service"]
101103
pg_creds = tools_os.manage_pg_service(service)
102-
user = credentials.get("user") or pg_creds.get("user")
103-
password = credentials.get("password") if credentials.get("password") is not None else pg_creds.get("password")
104+
user = credentials.get("user") if credentials.get("user") not in (None, "") else pg_creds.get("user")
105+
password = credentials.get("password") if credentials.get("password") not in (None, "") else pg_creds.get("password")
104106

105107
if user not in (None, "") and password is not None:
106108
credentials["user"] = user

0 commit comments

Comments
 (0)