: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(webflow): surface a clear error for an invalid Site ID (#72505)
Tom Owers78ee7739fc3c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.pyindex dfdf008c8b61..6a8cb409a7e8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/tests/test_webflow.py@@ -207,6 +207,7 @@ class TestValidateCredentials:("bad_token", 401, None, False),("missing_scope_at_create", 403, None, True),("missing_scope_for_schema", 403, "products", False),+ ("invalid_site_id", 400, None, False),("site_not_found", 404, None, False),("server_error", 500, None, False),]@@ -217,6 +218,18 @@ class TestValidateCredentials:ok, _error = validate_credentials("token", "site-1", schema_name)assert ok is expected_ok+ def test_invalid_site_id_400_does_not_leak_raw_envelope(self) -> None:+ # A malformed Site ID gets a 400 with Webflow's raw "Validation Error: ..." envelope, which+ # must not surface to the user.+ with patch(TRANSPORT) as MockSession:+ MockSession.return_value.get.return_value = _make_response(+ {"message": "Validation Error: Provided IDs are invalid: Site ID"}, status_code=400+ )+ ok, error = validate_credentials("token", "site-1")+ assert ok is False+ assert "Site ID isn't valid" in (error or "")+ assert "Validation Error" not in (error or "")+def test_request_exception_returns_error(self) -> None:with patch(TRANSPORT) as MockSession:MockSession.return_value.get.side_effect = requests.exceptions.ConnectionError("boom")diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.pyindex 520bf1ce5fdb..9fac285a849a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/webflow/webflow.py@@ -107,6 +107,15 @@ def validate_credentials(api_token: str, site_id: str, schema_name: Optional[strif response.status_code == 404:return False, f"Webflow site '{site_id}' was not found or is not accessible by this token"+ # A 400 means Webflow rejected the Site ID as malformed before looking it up — distinct from a+ # 404 for a well-formed but unknown/inaccessible id. Surface a clear message instead of leaking+ # Webflow's raw "Validation Error: ..." envelope.+ if response.status_code == 400:+ return (+ False,+ "The Webflow Site ID isn't valid. Check that you entered the Site ID (not the site name or URL) and try again.",+ )+try:message = response.json().get("message", response.text)except ValueError: