From a9c9311f39e9ca1df404383bd1ca5f15ffb2342f Mon Sep 17 00:00:00 2001 From: Mathias Bockwoldt Date: Thu, 17 Jul 2025 09:12:31 +0000 Subject: [PATCH 1/2] fix #3513 Re-throw the caught error with redacted details. --- packages/pg-connection-string/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/pg-connection-string/index.js b/packages/pg-connection-string/index.js index 867256012..e34eabf4c 100644 --- a/packages/pg-connection-string/index.js +++ b/packages/pg-connection-string/index.js @@ -35,6 +35,7 @@ function parse(str, options = {}) { } catch (err) { // Remove the input from the error message to avoid leaking sensitive information err.input && (err.input = '*****REDACTED*****') + throw err } // We'd like to use Object.fromEntries() here but Node.js 10 does not support it From e3e0acd264251ae6d336fb0b3e573e463fa863aa Mon Sep 17 00:00:00 2001 From: Mathias Bockwoldt Date: Thu, 17 Jul 2025 09:17:43 +0000 Subject: [PATCH 2/2] Update test --- packages/pg-connection-string/test/parse.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/pg-connection-string/test/parse.ts b/packages/pg-connection-string/test/parse.ts index 1ba636788..a58edbe9c 100644 --- a/packages/pg-connection-string/test/parse.ts +++ b/packages/pg-connection-string/test/parse.ts @@ -330,6 +330,7 @@ describe('parse', function () { parse(connectionString) } catch (err: unknown) { expect(JSON.stringify(err)).to.not.include(password, 'Password should not be in the error message') + expect(JSON.stringify(err)).to.include('REDACTED', 'The thrown error should contain the redacted URL') return } throw new Error('Expected an error to be thrown')