fix(server): sanitize DB_URL for pg_dumpall to remove unknown query params (#23333)

Co-authored-by: Greg Lutostanski <greg.lutostanski@mobilityhouse.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
Greg Lutostanski
2025-11-24 09:34:21 -06:00
committed by GitHub
parent 57be3ff8c7
commit aecf064ec9
3 changed files with 42 additions and 3 deletions

View File

@@ -81,8 +81,16 @@ export class BackupService extends BaseService {
const isUrlConnection = config.connectionType === 'url';
let connectionUrl: string = isUrlConnection ? config.url : '';
if (URL.canParse(connectionUrl)) {
// remove known bad url parameters for pg_dumpall
const url = new URL(connectionUrl);
url.searchParams.delete('uselibpqcompat');
connectionUrl = url.toString();
}
const databaseParams = isUrlConnection
? ['--dbname', config.url]
? ['--dbname', connectionUrl]
: [
'--username',
config.username,
@@ -118,7 +126,7 @@ export class BackupService extends BaseService {
{
env: {
PATH: process.env.PATH,
PGPASSWORD: isUrlConnection ? new URL(config.url).password : config.password,
PGPASSWORD: isUrlConnection ? new URL(connectionUrl).password : config.password,
},
},
);