: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(vwo): surface VWO error messages when the data envelope is missing (#124226)
Tom Owers1bace50da6cf
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/tests/test_vwo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/tests/test_vwo.pyindex a3d81bcf1015..3543a4e9e4f8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/tests/test_vwo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/tests/test_vwo.py@@ -3,6 +3,7 @@ from typing import Anyimport pytest+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matchesfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (ScriptedResponse,SourceDriver,@@ -90,17 +91,19 @@ def test_report_empty_collection_terminates(empty: Any) -> None:@pytest.mark.parametrize(- "body",+ "body,non_retryable",[- {"_errors": [{"code": 401, "message": "Authentication Failed"}]},- {"_data": {"unexpected": []}},- {"_data": ["bad row"]},+ ({"_errors": [{"code": 401, "message": "Authentication Failed"}]}, True),+ ({"_errors": [{"code": 400, "message": "Invalid request"}]}, False),+ ({"_data": {"unexpected": []}}, False),+ ({"_data": ["bad row"]}, False),],)-def test_invalid_envelopes_fail_instead_of_replacing_with_empty_data(body: dict[str, Any]) -> None:+def test_invalid_envelopes_fail_instead_of_replacing_with_empty_data(body: dict[str, Any], non_retryable: bool) -> None:result = driver().run("campaigns", [ScriptedResponse(json=body)])assert isinstance(result.raised, ValueError)assert result.rows == []+ assert error_message_matches(str(result.raised), VWOSource().get_non_retryable_errors()) is non_retryable@pytest.mark.parametrize(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/vwo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/vwo.pyindex 2b6bfbe37ebf..2f980e0805a0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/vwo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vwo/vwo.py@@ -41,11 +41,26 @@ class VWOResumeConfig:paginator_state: dict[str, Any]+def vwo_error_detail(body: Any) -> str:+ # VWO can report a failure as a 200 with an `_errors` list, so its message must reach the error classifier.+ errors = body.get("_errors") if isinstance(body, dict) else None+ if not isinstance(errors, list):+ return ""+ messages = [+ f"{error['code']}: {error['message']}" if error.get("code") is not None else str(error["message"])+ for error in errors+ if isinstance(error, dict) and error.get("message")+ ]+ return f" ({'; '.join(messages)[:200]})" if messages else ""++class VWOCollectionSelector(JSONPath):# The campaign example is malformed. Accept flat and partialCollection envelopes without selecting nested goals.def find(self, data: Any) -> list[DatumInContext]:if not isinstance(data, dict) or "_data" not in data:- raise ValueError("VWO returned no data envelope. Check the token permissions and API response.")+ raise ValueError(+ f"VWO returned no data envelope{vwo_error_detail(data)}. Check the token permissions and API response."+ )rows = data["_data"]if isinstance(rows, dict) and "partialCollection" in rows:rows = rows["partialCollection"]