: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): stop config parsing crashing on flat nested-config payloads (#63329)
Tom Owers539e70ca5365
diff --git a/posthog/temporal/data_imports/sources/common/test/test_config.py b/posthog/temporal/data_imports/sources/common/test/test_config.pyindex 1f3753e04116..a702f6611623 100644--- a/posthog/temporal/data_imports/sources/common/test/test_config.py+++ b/posthog/temporal/data_imports/sources/common/test/test_config.py@@ -323,23 +323,33 @@ def test_to_config_union_nested_configs_with_alias():@pytest.mark.parametrize(- "config_dict,expected_selection,expected_integration_id,expected_account_id",+ "config_dict,expected_selection,expected_integration_id,expected_secret_key,expected_account_id",[# Flat select payload: the option value as a scalar with the option's fields as# siblings. The scalar isn't mapped to `selection`, so it keeps its default and# the siblings are parsed flat.- ({"auth_method": "oauth", "integration_id": 123, "account_id": "acct_x"}, "api_key", 123, "acct_x"),+ ({"auth_method": "oauth", "integration_id": 123, "account_id": "acct_x"}, "api_key", 123, None, "acct_x"),+ # Flat payload whose scalar sibling is a string field — it must survive the flat+ # fallback and land on the nested config (e.g. Stripe's `secret_key`).+ (+ {"auth_method": "api_key", "secret_key": "rk_live_x", "account_id": "acct_123"},+ "api_key",+ None,+ "rk_live_x",+ "acct_123",+ ),# Nested form keeps working unchanged.({"auth_method": {"selection": "oauth", "integration_id": 456}, "account_id": "acct_y"},"oauth",456,+ None,"acct_y",),],)def test_to_config_scalar_under_nested_config_key(- config_dict, expected_selection, expected_integration_id, expected_account_id+ config_dict, expected_selection, expected_integration_id, expected_secret_key, expected_account_id):"""A scalar under a nested-config key must not crash `to_config`.@@ -355,6 +365,7 @@ def test_to_config_scalar_under_nested_config_key(class AuthMethod:selection: str = "api_key"integration_id: int | None = config.value(converter=config.str_to_optional_int, default_factory=lambda: None)+ secret_key: str | None = None@config.configclass SourceConfig(config.Config):@@ -371,6 +382,7 @@ def test_to_config_scalar_under_nested_config_key(assert isinstance(cfg.auth_method, AuthMethod)assert cfg.auth_method.selection == expected_selectionassert cfg.auth_method.integration_id == expected_integration_id+ assert cfg.auth_method.secret_key == expected_secret_keyassert cfg.account_id == expected_account_id