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): handle sources without schema discovery in setup (#65131)

Tom Owers1a39f73337e8
diff --git a/products/data_warehouse/backend/api/external_data_source.py b/products/data_warehouse/backend/api/external_data_source.py
index 578ab88e6d7c..c857b4e49ce8 100644
--- a/products/data_warehouse/backend/api/external_data_source.py
+++ b/products/data_warehouse/backend/api/external_data_source.py
@@ -2350,6 +2350,13 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
try:
source_schemas = source.get_schemas(source_config, self.team_id)
+ except NotImplementedError:
+ # Source doesn't implement schema discovery (e.g. an unreleased source) so it can't be
+ # set up via this one-shot flow — a caller mistake, not a server error worth capturing.
+ return Response(
+ status=status.HTTP_400_BAD_REQUEST,
+ data={"message": f"Source type '{source_type}' does not support one-shot setup."},
+ )
except Exception as e:
capture_exception(e, {"source_type": source_type, "team_id": self.team_id})
return Response(status=status.HTTP_400_BAD_REQUEST, data={"message": str(e)})
diff --git a/products/data_warehouse/backend/api/test/test_external_data_source.py b/products/data_warehouse/backend/api/test/test_external_data_source.py
index dbf50ce66d09..9b764a8edfeb 100644
--- a/products/data_warehouse/backend/api/test/test_external_data_source.py
+++ b/products/data_warehouse/backend/api/test/test_external_data_source.py
@@ -9134,6 +9134,18 @@ class TestExternalDataSourceSetup(APIBaseTest):
source = ExternalDataSource.objects.get(pk=response.json()["id"])
assert source.direct_query_enabled is False
+ @patch("products.data_warehouse.backend.api.external_data_source.capture_exception")
+ def test_setup_rejects_source_without_schema_discovery(self, mock_capture_exception):
+ # AmazonS3 doesn't implement get_schemas, so the base raises NotImplementedError.
+ response = self.client.post(
+ f"/api/environments/{self.team.pk}/external_data_sources/setup/",
+ data={"source_type": "AmazonS3", "prefix": "s3_setup_test", "payload": {}},
+ )
+ assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json()
+ assert "does not support one-shot setup" in response.json()["message"]
+ mock_capture_exception.assert_not_called()
+ assert not ExternalDataSource.objects.filter(team=self.team).exists()
+
def _create_stripe_webhook_template(self):
from products.cdp.backend.models.hog_function_template import HogFunctionTemplate