: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
feat(product-analytics): roll out validation for test account filters for mcp/api (#58320)
Thomas Obermüller637c0b5cad30
diff --git a/posthog/api/team.py b/posthog/api/team.pyindex 062c1dfb82f5..61fedb0900b6 100644--- a/posthog/api/team.py+++ b/posthog/api/team.py@@ -391,9 +391,6 @@ test_account_filters_adapter = TypeAdapter(list[AnyPropertyFilter])def validate_test_account_filters(value: object) -> list[dict[str, object]]:- if not getattr(settings, "TEST_ACCOUNT_FILTERS_STRICT_VALIDATION_ENABLED", False):- return cast(list[dict[str, object]], value)-try:test_account_filters_adapter.validate_python(value)except PydanticValidationError as error:diff --git a/posthog/api/test/test_team.py b/posthog/api/test/test_team.pyindex ea92b9bf85a1..44fb85d6f3a9 100644--- a/posthog/api/test/test_team.py+++ b/posthog/api/test/test_team.py@@ -3255,11 +3255,10 @@ class TestTeamAPI(team_api_test_factory()): # type: ignore):original_test_account_filters = self.team.test_account_filters- with self.settings(TEST_ACCOUNT_FILTERS_STRICT_VALIDATION_ENABLED=True):- response = self.client.patch(- f"/api/environments/{self.team.id}/",- {"test_account_filters": test_account_filters},- )+ response = self.client.patch(+ f"/api/environments/{self.team.id}/",+ {"test_account_filters": test_account_filters},+ )self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)self.assertEqual(response.json()["attr"], "test_account_filters")@@ -3269,11 +3268,10 @@ class TestTeamAPI(team_api_test_factory()): # type: ignoreself.assertEqual(self.team.test_account_filters, original_test_account_filters)def test_validate_test_account_filters_allows_is_set_filters_without_value(self):- with self.settings(TEST_ACCOUNT_FILTERS_STRICT_VALIDATION_ENABLED=True):- response = self.client.patch(- f"/api/environments/{self.team.id}/",- {"test_account_filters": [{"key": "email", "type": "person", "operator": "is_set"}]},- )+ response = self.client.patch(+ f"/api/environments/{self.team.id}/",+ {"test_account_filters": [{"key": "email", "type": "person", "operator": "is_set"}]},+ )self.assertEqual(response.status_code, status.HTTP_200_OK)self.assertEqual(