: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): surface TemporalIO TLS cert failures as config errors (#63247)
Marcus Hof175a8ccf7ec7
diff --git a/posthog/temporal/data_imports/sources/temporalio/source.py b/posthog/temporal/data_imports/sources/temporalio/source.pyindex 64ae01ba6256..57c8771de90a 100644--- a/posthog/temporal/data_imports/sources/temporalio/source.py+++ b/posthog/temporal/data_imports/sources/temporalio/source.py@@ -30,6 +30,18 @@ class TemporalIOSource(ResumableSource[TemporalIOSourceConfig, TemporalIOResumeCdef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.TEMPORALIO+ def get_non_retryable_errors(self) -> dict[str, str | None]:+ # rustls surfaces mTLS rejections as TLS alert names inside the tonic transport+ # error. These are credential problems — retrying can never recover.+ return {+ "received fatal alert: UnknownCA": "Temporal rejected this source's client certificate because it is not signed by a certificate authority the namespace trusts. This usually means the namespace's CA certificates were rotated — update the source with a client certificate and key signed by the current CA.",+ "received fatal alert: CertificateExpired": "This source's client certificate has expired. Update the source with a renewed client certificate and key.",+ "received fatal alert: CertificateRevoked": "This source's client certificate has been revoked. Update the source with a new client certificate and key.",+ "received fatal alert: BadCertificate": "Temporal rejected this source's client certificate as invalid. Update the source with a valid client certificate and key.",+ "received fatal alert: CertificateUnknown": "Temporal rejected this source's client certificate. Update the source with a valid client certificate and key.",+ "invalid peer certificate": "The Temporal server's certificate could not be verified. Check the host and port point at your Temporal namespace's gRPC endpoint.",+ }+def get_schemas(self,config: TemporalIOSourceConfig,diff --git a/posthog/temporal/data_imports/sources/temporalio/test_temporalio.py b/posthog/temporal/data_imports/sources/temporalio/test_temporalio.pyindex 6bc237989516..a5b1c2e6761c 100644--- a/posthog/temporal/data_imports/sources/temporalio/test_temporalio.py+++ b/posthog/temporal/data_imports/sources/temporalio/test_temporalio.py@@ -1,9 +1,11 @@+import pytestfrom unittest.mock import AsyncMock, MagicMock, patchfrom temporalio.client import Clientfrom posthog.temporal.common.codec import EncryptionCodecfrom posthog.temporal.data_imports.sources.generated_configs import TemporalIOSourceConfig+from posthog.temporal.data_imports.sources.temporalio.source import TemporalIOSourcefrom posthog.temporal.data_imports.sources.temporalio.temporalio import FakeSettings, _get_temporal_client@@ -34,3 +36,40 @@ class TestTemporalIOClient:data_converter = mock_connect.call_args.kwargs["data_converter"]assert isinstance(data_converter.payload_codec, EncryptionCodec)+++class TestTemporalIONonRetryableErrors:+ def setup_method(self):+ self.source = TemporalIOSource()++ @pytest.mark.parametrize(+ "error_message",+ [+ 'RuntimeError: Failed client connect: `get_system_info` call error after connection: Status { code: Unknown, message: "transport error", source: Some(tonic::transport::Error(Transport, hyper::Error(Io, Custom { kind: InvalidData, error: "received fatal alert: UnknownCA" }))) }',+ "received fatal alert: CertificateExpired",+ "received fatal alert: CertificateRevoked",+ "received fatal alert: BadCertificate",+ "received fatal alert: CertificateUnknown",+ "invalid peer certificate: UnknownIssuer",+ ],+ )+ def test_tls_certificate_failures_are_non_retryable(self, error_message):+ non_retryable_errors = self.source.get_non_retryable_errors()++ assert any(pattern in error_message for pattern in non_retryable_errors), (+ f"Expected '{error_message}' to match a non-retryable pattern"+ )++ @pytest.mark.parametrize(+ "error_message",+ [+ "activity Heartbeat timeout",+ 'RuntimeError: Failed client connect: `get_system_info` call error after connection: Status { code: Unknown, message: "transport error", source: Some(tonic::transport::Error(Transport, hyper::Error(Io, Os { code: 60, kind: TimedOut, message: "Operation timed out" }))) }',+ ],+ )+ def test_transient_failures_stay_retryable(self, error_message):+ non_retryable_errors = self.source.get_non_retryable_errors()++ assert not any(pattern in error_message for pattern in non_retryable_errors), (+ f"'{error_message}' must not match a non-retryable pattern"+ )