From 3d596e2dbcc7f0c30b9633df60e5a12a90257028 Mon Sep 17 00:00:00 2001 From: net <96362337+netqo@users.noreply.github.com> Date: Wed, 3 Jun 2026 04:50:24 -0300 Subject: [PATCH] fix: don't mention retrying in the database connection error message The PGRST000 database connection error message was "Database connection error. Retrying the connection.", but reconnection attempts are already logged separately by the reconnection observation, and on fatal errors (e.g. authentication failure) PostgREST does not retry at all. Drop the "Retrying the connection." part, leaving "Database connection error.". --- CHANGELOG.md | 2 ++ src/PostgREST/Error.hs | 2 +- test/io/test_io.py | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 575c86f68..2d75f8b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ All notable changes to this project will be documented in this file. From versio - Shutdown should wait for in flight requests by @mkleczek in #4702 - Remove automatic transaction retries on `40001 (serialization_failure)` errors to prevent replication lag by @laurenceisla in #3673 - Fix unexpected results when embedding and filtering the same table more than once by @laurenceisla in #4075 +- Fix connection retrying message in `PGRST000` error by @netqo in #4980 + + Remove redundant "Retrying the connection." from message because it is logged separately ### Changed diff --git a/src/PostgREST/Error.hs b/src/PostgREST/Error.hs index 2399adf81..b6e1d0cc0 100644 --- a/src/PostgREST/Error.hs +++ b/src/PostgREST/Error.hs @@ -475,7 +475,7 @@ instance ErrorBody SQL.UsageError where code (SQL.SessionUsageError (SQL.QueryError _ _ e)) = code e code SQL.AcquisitionTimeoutUsageError = "PGRST003" - message (SQL.ConnectionUsageError _) = "Database connection error. Retrying the connection." + message (SQL.ConnectionUsageError _) = "Database connection error." message (SQL.SessionUsageError (SQL.PipelineError e)) = message e message (SQL.SessionUsageError (SQL.QueryError _ _ e)) = message e message SQL.AcquisitionTimeoutUsageError = "Timed out acquiring connection from connection pool." diff --git a/test/io/test_io.py b/test/io/test_io.py index aa3e923dc..6c20c0d0f 100644 --- a/test/io/test_io.py +++ b/test/io/test_io.py @@ -2058,6 +2058,15 @@ def test_log_listener_connection_start(defaultenv): ) +def test_connection_error_message_does_not_claim_retry(defaultenv): + "The connection error message should not claim retrying, since PostgREST stops on fatal errors." + uri = f'postgresql://?dbname={defaultenv["PGDATABASE"]}&host={defaultenv["PGHOST"]}&user=some_protected_user&password=invalid_pass' + env = {**defaultenv, "PGRST_DB_URI": uri} + with run(env=env, no_startup_stdout=False, wait_for=None) as postgrest: + output = postgrest.read_stdout(nlines=8) + assert any('"message":"Database connection error."' in line for line in output) + + def test_db_pre_config_with_pg_reserved_words(defaultenv): "The db-pre-config should not fail unexpectedly when function name is a postgres reserved word"