: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): handle sources without schema discovery in database_schema (#68114)
Tom Owerse40f2968a3d2
diff --git a/products/data_warehouse/backend/presentation/views/external_data_source.py b/products/data_warehouse/backend/presentation/views/external_data_source.pyindex 1946e7a33245..53fe12a48fec 100644--- a/products/data_warehouse/backend/presentation/views/external_data_source.py+++ b/products/data_warehouse/backend/presentation/views/external_data_source.py@@ -2666,6 +2666,13 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixitry:schemas = source.get_schemas(source_config, self.team_id)+ except NotImplementedError:+ # Source doesn't implement schema discovery (e.g. an unreleased source), so there are+ # no tables to list — a caller mistake, not a server error worth capturing. Mirrors `setup`.+ return Response(+ status=status.HTTP_400_BAD_REQUEST,+ data={"message": f"Source type '{source_type}' does not support schema discovery."},+ )except Exception as e:error_message, is_expected_source_error = _classify_refresh_schemas_error(source, e)if not is_expected_source_error: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 2d4de35137ea..56b45c70f9e0 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@@ -4070,6 +4070,30 @@ class TestExternalDataSource(APIBaseTest):assert response.json()["message"] == str(error)mock_capture_exception.assert_not_called()+ @patch("products.data_warehouse.backend.presentation.views.external_data_source.capture_exception")+ @patch("products.data_warehouse.backend.presentation.views.external_data_source.SourceRegistry.get_source")+ def test_database_schema_rejects_source_without_schema_discovery(self, mock_get_source, mock_capture_exception):+ # AmazonS3 deliberately omits get_schemas, so the base raises NotImplementedError. The endpoint+ # must return a clean 400 without capturing it as a server error, mirroring `setup`.+ from products.warehouse_sources.backend.temporal.data_imports.sources.amazon_s3.source import AmazonS3Source++ source = AmazonS3Source()+ mock_get_source.return_value = source++ with (+ patch.object(source, "validate_config", return_value=(True, [])),+ patch.object(source, "parse_config", return_value=None),+ patch.object(source, "validate_credentials", return_value=(True, None)),+ ):+ response = self.client.post(+ f"/api/environments/{self.team.pk}/external_data_sources/database_schema/",+ data={"source_type": "AmazonS3"},+ )++ assert response.status_code == 400+ assert response.json()["message"] == "Source type 'AmazonS3' does not support schema discovery."+ mock_capture_exception.assert_not_called()+def test_database_schema_stripe_surfaces_per_endpoint_permission_errors(self):"""Schema-selection step calls get_endpoint_permissions and merges the per-endpointresult into each schema row so the UI can disable tables the credentials can't reach."""