Problem
The PostgreSQL extension currently requires a password to be stored either in VS Code's secret storage (interactive only) or inline in the connection string. In corporate and CI environments, developers use a ~/.pgpass file (the standard PostgreSQL password file) to supply credentials without interactive prompts. The extension does not read .pgpass and instead always shows a password prompt or fails with authentication failed.
.pgpass format (for context)
# hostname:port:database:username:password
db.corp.example.com:5432:mydb:myuser:s3cr3t
*:5432:*:ci_runner:ci_password
File lives at ~/.pgpass (Unix) or %APPDATA%\postgresql\pgpass.conf (Windows). PostgreSQL's libpq reads it automatically, but the extension's custom connection logic bypasses it.
Steps to Reproduce
- Create a valid
~/.pgpass (or %APPDATA%\postgresql\pgpass.conf on Windows).
- In the extension, add a new connection with the matching host/port/db/user — leave password blank.
- Click Connect.
- Result:
password authentication failed — extension never read .pgpass.
Expected Behaviour
Before prompting for a password, the extension should check .pgpass (standard location per OS) and use the matching entry if found. This aligns with psql/pg_dump CLI behaviour.
Proposed Implementation
- Add a utility
resolvePgpass(host, port, db, user) that reads and parses .pgpass from the OS-appropriate location.
- Call it during connection before falling back to the password prompt.
- Add a
pgsql.pgpassFile setting to override the default path (useful for CI where .pgpass is at a non-standard location).
Environment
- OS: Windows 11 Enterprise (path:
%APPDATA%\postgresql\pgpass.conf) and Linux CI
- VS Code: 1.89+
- Extension: ms-ossdata.vscode-pgsql latest
Problem
The PostgreSQL extension currently requires a password to be stored either in VS Code's secret storage (interactive only) or inline in the connection string. In corporate and CI environments, developers use a
~/.pgpassfile (the standard PostgreSQL password file) to supply credentials without interactive prompts. The extension does not read.pgpassand instead always shows a password prompt or fails withauthentication failed..pgpass format (for context)
File lives at
~/.pgpass(Unix) or%APPDATA%\postgresql\pgpass.conf(Windows). PostgreSQL'slibpqreads it automatically, but the extension's custom connection logic bypasses it.Steps to Reproduce
~/.pgpass(or%APPDATA%\postgresql\pgpass.confon Windows).password authentication failed— extension never read.pgpass.Expected Behaviour
Before prompting for a password, the extension should check
.pgpass(standard location per OS) and use the matching entry if found. This aligns withpsql/pg_dumpCLI behaviour.Proposed Implementation
resolvePgpass(host, port, db, user)that reads and parses.pgpassfrom the OS-appropriate location.pgsql.pgpassFilesetting to override the default path (useful for CI where.pgpassis at a non-standard location).Environment
%APPDATA%\postgresql\pgpass.conf) and Linux CI