File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -189,8 +189,9 @@ export function resolveAdminConnection(opts: {
189189 const conn = ( opts . conn || "" ) . trim ( ) ;
190190 const dbUrlFlag = ( opts . dbUrlFlag || "" ) . trim ( ) ;
191191
192- const hasPsqlParts =
193- ! ! ( opts . host || opts . port || opts . username || opts . dbname || opts . adminPassword || opts . envPassword ) ;
192+ // NOTE: passwords alone (PGPASSWORD / --admin-password) do NOT constitute a connection.
193+ // We require at least some connection addressing (host/port/user/db) if no positional arg / --db-url is provided.
194+ const hasConnDetails = ! ! ( opts . host || opts . port || opts . username || opts . dbname ) ;
194195
195196 if ( conn && dbUrlFlag ) {
196197 throw new Error ( "Provide either positional connection string or --db-url, not both" ) ;
@@ -207,7 +208,7 @@ export function resolveAdminConnection(opts: {
207208 return { clientConfig : cfg , display : describePgConfig ( cfg ) } ;
208209 }
209210
210- if ( ! hasPsqlParts ) {
211+ if ( ! hasConnDetails ) {
211212 throw new Error (
212213 [
213214 "Connection is required." ,
Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ test("resolveAdminConnection rejects invalid psql-like port", () => {
9191 ) ;
9292} ) ;
9393
94+ test ( "resolveAdminConnection rejects when only PGPASSWORD is provided (no connection details)" , ( ) => {
95+ assert . throws ( ( ) => init . resolveAdminConnection ( { envPassword : "pw" } ) , / C o n n e c t i o n i s r e q u i r e d / ) ;
96+ } ) ;
97+
9498test ( "print-sql redaction regex matches password literal with embedded quotes" , async ( ) => {
9599 const plan = await init . buildInitPlan ( {
96100 database : "mydb" ,
You can’t perform that action at this time.
0 commit comments