Skip to content

: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.

fix(data-warehouse): clarify the error shown when a second same-type source needs a prefix (#69861)

Tom Owersc75b0ae1d4ba
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.py
index 5989eff3fb21..61d05928cc7d 100644
--- a/products/data_warehouse/backend/presentation/views/external_data_source.py
+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py
@@ -1857,7 +1857,9 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
if self.prefix_required(source_type):
return Response(
status=status.HTTP_400_BAD_REQUEST,
- data={"message": "Source type already exists. Prefix is required"},
+ data={
+ "message": "You already have a source of this type. Add a table prefix so this connection's tables don't clash with your existing source."
+ },
)
elif self.prefix_exists(source_type, prefix):
return Response(status=status.HTTP_400_BAD_REQUEST, data={"message": "Prefix already exists"})
@@ -3904,7 +3906,9 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
if self.prefix_required(source_type):
return Response(
status=status.HTTP_400_BAD_REQUEST,
- data={"message": "Source type already exists. Prefix is required"},
+ data={
+ "message": "You already have a source of this type. Add a table prefix so this connection's tables don't clash with your existing source."
+ },
)
elif self.prefix_exists(source_type, prefix):
return Response(status=status.HTTP_400_BAD_REQUEST, data={"message": "Prefix already exists"})
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.py
index 3da08f1cd283..57d00d6d6dab 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
@@ -1015,7 +1015,12 @@ class TestExternalDataSource(APIBaseTest):
)
self.assertEqual(response.status_code, 400)
- self.assertEqual(response.json(), {"message": "Source type already exists. Prefix is required"})
+ self.assertEqual(
+ response.json(),
+ {
+ "message": "You already have a source of this type. Add a table prefix so this connection's tables don't clash with your existing source."
+ },
+ )
# Create with prefix
response = self.client.post(
@@ -1130,14 +1135,14 @@ class TestExternalDataSource(APIBaseTest):
[(None, False)],
"",
400,
- "Source type already exists. Prefix is required",
+ "You already have a source of this type. Add a table prefix so this connection's tables don't clash with your existing source.",
),
(
"no-prefix source (empty string) blocks another no-prefix",
[("", False)],
"",
400,
- "Source type already exists. Prefix is required",
+ "You already have a source of this type. Add a table prefix so this connection's tables don't clash with your existing source.",
),
(
"no-prefix source still allows a prefixed source",