Refuse a malformed admin DSN before postgres 4 connects to the host it misreads
CI / full-gate (push) Successful in 3m58s
Mirror / github-mirror (push) Waiting to run

This commit was merged in pull request #169.
This commit is contained in:
2026-11-08 23:17:54 +01:00
parent 44f94c7ab0
commit 0a9c79d08f
+1
View File
@@ -20,6 +20,7 @@ export interface ProvisionResult {
// so it is swallowed here. The driver, not `new URL`, decides what parses: it takes a multi-host DSN.
function connect(adminUrl: string): ReturnType<typeof postgres> {
try {
new URL(adminUrl); // postgres 4 connects to whatever a malformed DSN parses to, and its error names that host
return postgres(adminUrl, { connect_timeout: 10, max: 1 });
} catch {
throw new Error("PLUGIN_DB_ADMIN_URL must be a Postgres URL (its value is not shown; percent-encode special characters in a password)");