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): give an actionable message for Mixpanel 402 (#70208)

Tom Owers49bab15f318c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/mixpanel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/mixpanel.py
index bdc8d5947bb2..c5df441d4fab 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/mixpanel.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/mixpanel.py
@@ -183,6 +183,13 @@ def validate_credentials(
if schema_name is None:
return True, None
return False, "The service account does not have access to this resource in the selected project."
+ if response.status_code == 402:
+ return (
+ False,
+ "Mixpanel denied the request (402 Payment Required). Raw data access usually needs a Mixpanel "
+ "plan that includes the data export API, and the account must be in good standing. Check your "
+ "Mixpanel plan and billing, then try again.",
+ )
return False, f"Mixpanel returned an unexpected status ({response.status_code}) while validating credentials."
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/test_mixpanel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/test_mixpanel.py
index efc41b9ee669..c6e276368165 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/test_mixpanel.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/test_mixpanel.py
@@ -260,6 +260,16 @@ class TestValidateCredentials:
assert ok is False
assert error is not None
+ def test_payment_required_gets_actionable_message(self) -> None:
+ session = MagicMock()
+ session.post.return_value = FakeResponse(status_code=402)
+ with patch.object(mp, "make_tracked_session", return_value=session):
+ ok, error = validate_credentials("us", "user", "secret", "123")
+ assert ok is False
+ assert error is not None
+ assert "402" in error
+ assert "plan" in error.lower()
+
class TestExportIterator:
def _run(self, manager: FakeManager, start: date, end: date, responses: list[FakeResponse]) -> list[dict]: