: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): make duplicate-prefix source error actionable (#71083)
Tom Owers202bb18b39db
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.pyindex 87151406d9da..d1f00b4a13f5 100644--- a/products/data_warehouse/backend/presentation/views/external_data_source.py+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py@@ -2050,7 +2050,12 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi},)elif self.prefix_exists(source_type, prefix):- return Response(status=status.HTTP_400_BAD_REQUEST, data={"message": "Prefix already exists"})+ return Response(+ status=status.HTTP_400_BAD_REQUEST,+ data={+ "message": f"Another source of this type already uses the prefix '{prefix}'. Choose a different prefix so this connection's tables don't clash."+ },+ )if access_method == ExternalDataSource.AccessMethod.WAREHOUSE and is_any_external_data_schema_paused(self.team_id@@ -4132,7 +4137,12 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi},)elif self.prefix_exists(source_type, prefix):- return Response(status=status.HTTP_400_BAD_REQUEST, data={"message": "Prefix already exists"})+ return Response(+ status=status.HTTP_400_BAD_REQUEST,+ data={+ "message": f"Another source of this type already uses the prefix '{prefix}'. Choose a different prefix so this connection's tables don't clash."+ },+ )return Response(status=status.HTTP_200_OK)diff --git a/products/data_warehouse/backend/tests/api/test_external_data_source.py b/products/data_warehouse/backend/tests/api/test_external_data_source.pyindex 23f8a0720839..fc284b2c7282 100644--- a/products/data_warehouse/backend/tests/api/test_external_data_source.py+++ b/products/data_warehouse/backend/tests/api/test_external_data_source.py@@ -1195,7 +1195,12 @@ class TestExternalDataSource(APIBaseTest):)self.assertEqual(response.status_code, 400)- self.assertEqual(response.json(), {"message": "Prefix already exists"})+ self.assertEqual(+ response.json(),+ {+ "message": "Another source of this type already uses the prefix 'test_'. Choose a different prefix so this connection's tables don't clash."+ },+ )def _make_external_data_source(self, source_type: str = "Postgres", prefix: t.Optional[str] = None, deleted: bool = False@@ -1236,7 +1241,7 @@ class TestExternalDataSource(APIBaseTest):[("foo_", False)],"foo_",400,- "Prefix already exists",+ "Another source of this type already uses the prefix 'foo_'. Choose a different prefix so this connection's tables don't clash.",),("no-prefix source (null) blocks another no-prefix",