Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes and improvements about connection password need detection #391

Merged
merged 4 commits into from
Aug 21, 2023

Conversation

dlax
Copy link
Member

@dlax dlax commented Jul 6, 2023

Based on #390 (first commit).

dlax added 4 commits July 6, 2023 12:08
The string 'fe_sendauth: ...' is just a part of the error message, so we
must not check for equality.
The second argument passed to pg_connect() is expected to be a
'exit_on_failed: bool', but we were passing the connection string. So when
the connection string is given by the user, it behaves similarly as
passing True (non-empty string evaluates to True); on the other hand, if
no connection string is passed, it evaluates to False, which disables
the 'exit_on_failed' feature. In fact, this exit_on_failed parameter is
never used by caller, so let's just remove it.
Psycopg 3 links exceptions to the underlying libpq PGconn object, which
exposes a 'needs_password' property; exactly what we need and much more
robust than parsing the error message.
@dlax dlax requested a review from blogh July 6, 2023 10:09
@dlax dlax merged commit 4ccefc7 into dalibo:master Aug 21, 2023
3 checks passed
@dlax dlax deleted the exit-on-failed branch August 21, 2023 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant