Skip to content

: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.

fix(postgres): stop retrying an unnamed provider quota refusal (#103325)

Tom Owers7c5d218ad71d
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.py
index df86518033c6..6b93cd5645ed 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
@@ -882,6 +882,15 @@ class PostgresSource(SQLSource[PostgresSourceConfig], SSHTunnelMixin, ValidateDa
"transfer quota. Upgrade your provider's plan or wait for the quota to reset, then "
"re-enable the sync."
),
+ # The same provider family names some quotas in the refusal and others not at all
+ # ("has exceeded the quota"), so the two keys above miss those wordings and the raw
+ # libpq line — carrying the customer's host and port — is retried and then stored.
+ # Every variant ends in the same provider sentence, so match that instead of each
+ # quota name. Placed last so the two entries above keep their more specific copy.
+ "quota. Upgrade your plan to increase limits": (
+ "Your database provider blocked the connection because your project exceeded a plan "
+ "quota. Upgrade the plan or wait for the quota to reset, then re-enable the sync."
+ ),
# A database proxy (observed on Prisma Accelerate) refuses the connection because the
# account hit a plan limit, reporting "Your account has restrictions: planLimitReached".
# The restriction is account-level state only the customer can lift (upgrade the plan or
diff --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.py
index 131ebe963137..6d0b0db050e6 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
@@ -810,6 +810,16 @@ class TestPostgresSourceNonRetryableErrors:
"OperationalError: Your project has exceeded the data transfer quota. Upgrade your plan to increase limits.",
"data transfer quota",
),
+ # Some refusals from the same family name no quota at all, so only the sentence they
+ # all end with is left to classify them by.
+ (
+ 'connection failed: connection to server at "203.0.113.10", port 5432 failed: ERROR: Your account or project has exceeded the quota. Upgrade your plan to increase limits.',
+ "a plan quota",
+ ),
+ (
+ "OperationalError: Your account or project has exceeded the quota. Upgrade your plan to increase limits.",
+ "a plan quota",
+ ),
],
)
def test_exceeded_provider_quota_is_non_retryable_with_friendly_message(self, source, error_msg, expected_fragment):