: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): align temporalio FakeSettings with codec contract (#61539)
estefania6743419193bc
diff --git a/posthog/temporal/data_imports/sources/temporalio/temporalio.py b/posthog/temporal/data_imports/sources/temporalio/temporalio.pyindex 17806b5ce77b..0bf18a148d5d 100644--- a/posthog/temporal/data_imports/sources/temporalio/temporalio.py+++ b/posthog/temporal/data_imports/sources/temporalio/temporalio.py@@ -3,6 +3,7 @@ import asyncioimport datetimeimport threadingimport dataclasses+from collections.abc import Iterablefrom enum import StrEnumfrom queue import Queuefrom typing import Any, Optional@@ -110,7 +111,10 @@ def _sanitize(obj):class FakeSettings:"""Required to trick temporal.io client to think its reading from django settings"""- SECRET_KEY: str+ TEMPORAL_SECRET_KEY: str | bytes+ TEMPORAL_FALLBACK_KEYS: Iterable[str | bytes] = dataclasses.field(default_factory=list)+ TEST: bool = False+ DEBUG: bool = Falseasync def _get_temporal_client(config: TemporalIOSourceConfig) -> Client:diff --git a/posthog/temporal/data_imports/sources/temporalio/test_temporalio.py b/posthog/temporal/data_imports/sources/temporalio/test_temporalio.pynew file mode 100644index 000000000000..9d8106cd2ded--- /dev/null+++ b/posthog/temporal/data_imports/sources/temporalio/test_temporalio.py@@ -0,0 +1,36 @@+from unittest.mock import AsyncMock, MagicMock, patch++from temporalio.client import Client++from posthog.temporal.common.codec import EncryptionCodec+from posthog.temporal.data_imports.sources.generated_configs import TemporalIOSourceConfig+from posthog.temporal.data_imports.sources.temporalio.temporalio import FakeSettings, _get_temporal_client+++class TestTemporalIOClient:+ def test_fake_settings_satisfies_encryption_codec_contract(self):+ # FakeSettings must expose every attribute EncryptionCodec.from_settings reads+ # (TEST, DEBUG, TEMPORAL_SECRET_KEY, TEMPORAL_FALLBACK_KEYS); a missing one raises+ # AttributeError. The 32-byte key clears the prod (TEST=False) length guard.+ codec = EncryptionCodec.from_settings(FakeSettings(TEMPORAL_SECRET_KEY="k" * 32))++ assert isinstance(codec, EncryptionCodec)++ async def test_get_temporal_client_builds_encryption_codec(self):+ config = TemporalIOSourceConfig.from_dict(+ {+ "host": "host",+ "port": "7233",+ "namespace": "namespace",+ "encryption_key": "k" * 32,+ "server_client_root_ca": "ca",+ "client_certificate": "cert",+ "client_private_key": "key",+ }+ )++ with patch.object(Client, "connect", new=AsyncMock(return_value=MagicMock())) as mock_connect:+ await _get_temporal_client(config)++ data_converter = mock_connect.call_args.kwargs["data_converter"]+ assert isinstance(data_converter.payload_codec, EncryptionCodec)