Skip to content

Defer PostgreSQL passfile lookup#3999

Closed
V02460 wants to merge 2 commits intolaunchbadge:mainfrom
V02460:pgpass-consistent-apply
Closed

Defer PostgreSQL passfile lookup#3999
V02460 wants to merge 2 commits intolaunchbadge:mainfrom
V02460:pgpass-consistent-apply

Conversation

@V02460
Copy link
Copy Markdown
Contributor

@V02460 V02460 commented Aug 25, 2025

Loads the the PostgreSQL passfile on apply_pgpass and defers querying the password to get_password calls. This ensures the correct password is retrieved, even when builder methods are called on PgConnectOptions after initialization.

Does your PR solve an issue?

Fixes #2658

Is this a breaking change?

Yes. Parameters set by PgConnectOptions builder methods are now honored by the passfile lookup.

@abonander
Copy link
Copy Markdown
Collaborator

I don't agree with implicitly attempting to re-apply the .pgpass file after construction and manual modification. I think that's going to be too surprising.

Consider a case like #3832 where the user doesn't even want the libpq behavior to begin with. This would be horrifying to them.

This would also break use-cases that need to implement password rotation, though that's also a really eclectic mix of concerns (.pgpass files shouldn't really be used in production, but if you are then why aren't you just re-reading the .pgpass file).

I think if we want this behavior, we should just expose the PgPassFile type (n.b. PGPassFile doesn't match the code style) and provide a way to apply a PgPassFile instance to an already-constructed PgConnectOptions.

@abonander abonander closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pgpass doesn't work with builder methods

2 participants