:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(warehouse-sources): stop retrying postgres proxy credential rejections (#99374)
Tom Owersbcd598b08fe0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.pyindex 94734366ba6b..966bf5a2691c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/source.py@@ -128,6 +128,13 @@ _HOST_RESOLUTION_RETRY_MESSAGE = (PostgresErrors = {"password authentication failed for user": _INVALID_CREDENTIALS_VALIDATION_ERROR,+ # A proxy/pooler in front of some providers rejects bad credentials during its own+ # database-identification step instead of libpq's "password authentication failed for user",+ # wrapping the rejection in its own sentence ("Failed to identify your database: Your Postgres+ # credentials are incorrect. Please check your username and password and try again."). None of+ # the password keys here substring-match it, so without this key validation falls through to+ # `capture_exception` and a generic fallback message. Match the stable, self-contained sentence.+ "Your Postgres credentials are incorrect": _INVALID_CREDENTIALS_VALIDATION_ERROR,# The bounded lookup in front of the connect reports a stalled resolver and a "try again"# answer as psycopg errors. Neither is a verdict on the host, so validation asks for a retry# rather than capturing a self-recovering failure.@@ -523,6 +530,13 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa# credential mismatch only the customer can fix. Match the stable, wording-independent# fragment shared by both forms."password authentication failed": _INVALID_CREDENTIALS_ERROR,+ # Twin of the `PostgresErrors` (validation-time) key above: a proxy/pooler in front of+ # some providers rejects bad credentials during its own database-identification step+ # instead of libpq's "password authentication failed for user" ("Failed to identify your+ # database: Your Postgres credentials are incorrect. Please check your username and+ # password and try again."). None of the password keys above substring-match it, so+ # without this key Temporal keeps retrying a credential mismatch only the customer can fix.+ "Your Postgres credentials are incorrect": _INVALID_CREDENTIALS_ERROR,# AWS RDS Proxy reports bad credentials with its own wording instead of PostgreSQL's# "password authentication failed for user" — it validates against Secrets Manager and# returns "The password that was provided for the role <role> is wrong." None of thediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.pyindex 5d2f05d2ae38..f28da1e7a107 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/postgres/test_postgres.py@@ -1099,6 +1099,24 @@ class TestPostgresSourceNonRetryableErrors:f"Password auth failure without 'for user' wording should be non-retryable: {error_msg}")+ @pytest.mark.parametrize(+ "error_msg",+ [+ # A proxy/pooler in front of some providers rejects bad credentials during its own+ # database-identification step, wrapping the rejection in its own sentence instead of+ # libpq's "password authentication failed for user". Host/IP and port are volatile.+ 'connection failed: connection to server at "66.135.14.99", port 5432 failed: '+ "Failed to identify your database: Your Postgres credentials are incorrect. "+ "Please check your username and password and try again.",+ ],+ )+ def test_identify_database_credentials_error_is_non_retryable(self, source, error_msg):+ non_retryable = source.get_non_retryable_errors()+ assert "Your Postgres credentials are incorrect" in non_retryable+ assert "password authentication failed" not in error_msg+ is_non_retryable = any(pattern in error_msg for pattern in non_retryable.keys())+ assert is_non_retryable, f"Proxy credentials rejection should be non-retryable: {error_msg}"+@pytest.mark.parametrize("error_msg",[@@ -4631,6 +4649,15 @@ class TestValidateCredentialsErrorMapping:'repeated authentication failures ("too many authentication failures"). This usually '"means the username or password is wrong. Check your credentials and try again.",),+ # A proxy/pooler in front of some providers rejects bad credentials during its own+ # database-identification step, wrapping the rejection in its own sentence instead of+ # libpq's "password authentication failed for user".+ (+ 'connection failed: connection to server at "66.135.14.99", port 5432 failed: '+ "Failed to identify your database: Your Postgres credentials are incorrect. "+ "Please check your username and password and try again.",+ "The database rejected the username or password. Check the user and password for this source and try again.",+ ),(f"{HOST_RESOLUTION_TIMEOUT_ERROR} after 15.0s","PostHog couldn't resolve your database host right now. Check the host name, then try "