: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(data-warehouse): say when a source's API was temporarily unavailable (#95754)
Tom Owers1c2f30e68288
diff --git a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.pyindex 3a2049154fc8..b8ff97dff2f7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py+++ b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py@@ -195,6 +195,10 @@ TRANSIENT_EGRESS_MESSAGE = ("clears on its own; the next sync runs on schedule.")+TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE = (+ "Your source's API was temporarily unavailable, so this sync couldn't finish. The next sync runs on schedule."+)+# A retryable failure that outlives its retries keeps whatever the driver said, so `latest_error`# ends up holding raw connection text — a psycopg "connection to server at <host>, port <port># failed: ..." line, a pymysql `(2013, ...)` tuple, a urllib3 connection-pool dump. None of it@@ -225,6 +229,14 @@ Transient_Error_Messages: dict[str, str] = {"Tunnel connection failed: 502": TRANSIENT_EGRESS_MESSAGE,"Tunnel connection failed: 503": TRANSIENT_EGRESS_MESSAGE,"Tunnel connection failed: 504": TRANSIENT_EGRESS_MESSAGE,+ # A vendor API that was down or overloaded, in the wording `requests.raise_for_status()` builds:+ # "<status> Server Error: <reason> for url: <url>". REST sources retry these in their transport+ # and again through Temporal, so reaching here means the outage outlasted both and the stored+ # text is a bare status plus the vendor URL. Only the gateway statuses are mapped: a 500 can be+ # one request the vendor mishandles every time, which is not an outage that clears on its own.+ "502 Server Error": TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE,+ "503 Server Error": TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE,+ "504 Server Error": TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE,}diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.pyindex 153a6e1399ed..6152100fb981 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py@@ -21,6 +21,7 @@ from products.warehouse_sources.backend.temporal.data_imports.external_data_jobTRANSIENT_EGRESS_MESSAGE,TRANSIENT_POOLER_MESSAGE,TRANSIENT_SOURCE_CONNECTION_MESSAGE,+ TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE,UNEXPECTED_ERROR_MESSAGE,UpdateExternalDataJobStatusInputs,_customer_facing_error,@@ -298,6 +299,13 @@ def test_read_only_transaction_disables_the_schema_only_when_the_source_raised_i"ProxyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 502 Bad gateway'))",TRANSIENT_EGRESS_MESSAGE,),+ # A REST source whose vendor stayed unavailable for longer than both retry layers.+ (+ "vendor_service_unavailable",+ ExternalDataSourceType.APPLESEARCHADS,+ "503 Server Error: Service Temporarily Unavailable for url: https://api.example.com/v1/things",+ TRANSIENT_VENDOR_UNAVAILABLE_MESSAGE,+ ),])@pytest.mark.django_db(transaction=True)