: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-imports): treat TLS handshake failure as non-retryable (#63768)
Tom Owers40e9b0b03f4e
diff --git a/posthog/temporal/data_imports/external_data_job.py b/posthog/temporal/data_imports/external_data_job.pyindex 8c7ce8034287..3c2475e1ec5c 100644--- a/posthog/temporal/data_imports/external_data_job.py+++ b/posthog/temporal/data_imports/external_data_job.py@@ -74,6 +74,12 @@ Any_Source_Errors: dict[str, str | None] = {"Primary key required for incremental syncs": None,"The primary keys for this table are not unique": None,"Integration matching query does not exist": "The connected account for this source is no longer available — it may have been disconnected. Please reconnect the source's account.",+ # A fatal TLS alert from the remote host (raised in the shared HTTP transport for every+ # REST-based source). The server refused the handshake, which is deterministic for a given+ # host/TLS config — retrying replays the identical failure, so it's not transient. Usually a+ # misconfigured or wrong host/URL on the customer's side. Match the stable alert name, not the+ # volatile `_ssl.c:NNNN` suffix or per-request host.+ "SSLV3_ALERT_HANDSHAKE_FAILURE": "Could not complete a secure (TLS) connection to the source's server — the handshake was rejected. Please check the configured host/URL is correct and that the server supports a compatible TLS version.",}diff --git a/posthog/temporal/tests/external_data/test_external_data_job.py b/posthog/temporal/tests/external_data/test_external_data_job.pyindex 9d99ddabdcf4..03a14a02fb4f 100644--- a/posthog/temporal/tests/external_data/test_external_data_job.py+++ b/posthog/temporal/tests/external_data/test_external_data_job.py@@ -517,6 +517,75 @@ async def test_update_external_job_activity_with_not_source_sepecific_non_retryaassert schema.should_sync is False+# The full message carries volatile parts (host, URL, `_ssl.c:NNNN`) around the stable alert name.+# Both `_ssl.c` line variants have been seen in the wild and must stay non-retryable.+ "tls_handshake_error",+ [+ (+ "SSLError(MaxRetryError(\"HTTPSConnectionPool(host='example.zendesk.com', port=443): "+ "Max retries exceeded with url: /api/v2/users?page%5Bsize%5D=100 (Caused by "+ "SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake "+ "failure (_ssl.c:1032)')))\"))"+ ),+ (+ "SSLError(MaxRetryError(\"HTTPSConnectionPool(host='example.zendesk.com', port=443): "+ "Max retries exceeded with url: /api/v2/users?page%5Bsize%5D=100 (Caused by "+ "SSLError(SSLError(1, '[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake "+ "failure (_ssl.c:1010)')))\"))"+ ),+ ],+)[email protected]_db(transaction=True)+async def test_update_external_job_activity_with_tls_handshake_failure_is_non_retryable(+ activity_environment, team, tls_handshake_error, **kwargs+):+ new_source = await sync_to_async(ExternalDataSource.objects.create)(+ source_id=str(uuid.uuid4()),+ connection_id=str(uuid.uuid4()),+ destination_id=str(uuid.uuid4()),+ team=team,+ status="running",+ source_type="Zendesk",+ )++ schema = await sync_to_async(ExternalDataSchema.objects.create)(+ name="test_123",+ team_id=team.id,+ source_id=new_source.pk,+ should_sync=True,+ )++ new_job = await _create_external_data_job(+ team_id=team.id,+ external_data_source_id=new_source.pk,+ workflow_id=activity_environment.info.workflow_id,+ workflow_run_id=activity_environment.info.workflow_run_id,+ external_data_schema_id=schema.id,+ )++ inputs = UpdateExternalDataJobStatusInputs(+ job_id=str(new_job.id),+ status=ExternalDataJob.Status.COMPLETED,+ latest_error=None,+ internal_error=tls_handshake_error,+ schema_id=str(schema.pk),+ source_id=str(new_source.pk),+ team_id=team.id,+ )+ with mock.patch(+ "products.data_warehouse.backend.data_load.service.external_data_workflow_exists",+ return_value=False,+ ):+ await activity_environment.run(update_external_data_job_model, inputs)++ await sync_to_async(new_job.refresh_from_db)()+ await sync_to_async(schema.refresh_from_db)()++ assert schema.should_sync is False++@pytest.fixturedef mock_stripe_client():with mock.patch("posthog.temporal.data_imports.sources.stripe.stripe.StripeClient") as MockStripeClient: