: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(warehouse-sources): surface webhook read failures in the UI (#104570)
jake sciottobaab83042bec
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.pyindex 5a1f4a8cab1b..a6c1ae144803 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_source/webhook_setup.py@@ -380,6 +380,10 @@ class ExternalDataSourceWebhookSetupMixin(base.ExternalDataSourceViewSetBase):missing_events = self._compute_missing_webhook_events(source, config, instance, external_status)except Exception as e:base.capture_exception(e)+ external_status = ExternalWebhookInfo(+ exists=False,+ error="PostHog couldn't read this source's webhook to check its status. Check the source's credentials, then reload.",+ )schema_mapping = {}if hog_function.inputs:diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.pyindex 8566befa67ce..d2485ec42280 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py@@ -9958,6 +9958,25 @@ class TestWebhookInfo(APIBaseTest):assert data["external_status"]["status"] == "enabled"assert data["external_status"]["enabled_events"] == ["charge.created", "charge.updated"]+ @patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.stripe.source.StripeSource.get_external_webhook_info"+ )+ def test_webhook_info_surfaces_read_failure(self, mock_get_info):+ mock_get_info.side_effect = Exception("cannot read webhook endpoint: sk_test_secret leaked here")++ source = self._create_stripe_source()+ self._create_hog_function(source)++ response = self.client.get(f"/api/environments/{self.team.pk}/external_data_sources/{source.pk}/webhook_info/")++ assert response.status_code == status.HTTP_200_OK+ data = response.json()+ assert data["exists"] is True+ assert data["external_status"] is not None+ assert data["external_status"]["exists"] is False+ assert data["external_status"]["error"]+ assert "sk_test_secret" not in data["external_status"]["error"]+@patch("products.warehouse_sources.backend.temporal.data_imports.sources.stripe.source.StripeSource.get_desired_webhook_events")