: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(mixpanel): drop http status codes from the plan and project id errors (#111321)
Tom Owersd20442e09b7b
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.pyindex 7fe89fc6b2c8..cafee3b3dbf1 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@@ -196,15 +196,14 @@ def validate_credentials(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.",+ "Your Mixpanel plan does not include data export, or its billing is overdue. Upgrade your "+ "Mixpanel plan or settle its billing, then try again.",)if response.status_code == 400:return (False,- "Mixpanel rejected the request (400). This usually means the project ID isn't valid for the "- "selected region. Check your project ID and region, then try again.",+ "Mixpanel did not find that project ID in the selected region. Check your project ID and "+ "region, then try again.",)return (diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/source.pyindex 315abe7c9c46..26ef51bdbe47 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixpanel/source.py@@ -173,8 +173,8 @@ Authenticate with a [Mixpanel Service Account](https://developer.mixpanel.com/re# Mixpanel returns 402 when the project's plan does not include the data export API or the# account is in a payment-overdue state. Retrying cannot resolve a billing issue."402 Client Error: Payment Required": (- "Mixpanel requires a paid plan that includes the data export API. Check your Mixpanel "- "plan and billing status, then try again."+ "Your Mixpanel plan does not include data export, or its billing is overdue. Upgrade your "+ "Mixpanel plan or settle its billing, then resync."),}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.pyindex 6804f2c47f14..62aa18e1aa97 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@@ -270,14 +270,20 @@ class TestValidateCredentials:else:assert error is not None- def test_bad_request_points_at_the_project_id(self) -> None:- # A 400 used to fall through and surface the raw status code, which is not actionable.+ @parameterized.expand(+ [+ ("bad_request", 400, "project ID"),+ ("payment_required", 402, "plan"),+ ]+ )+ def test_rejections_explain_the_fix_without_the_status_code(self, _name: str, status: int, hint: str) -> None:session = MagicMock()- session.post.return_value = FakeResponse(status_code=400)+ session.post.return_value = FakeResponse(status_code=status)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 and "project ID" in error+ assert error is not None and hint in error+ assert str(status) not in errordef test_network_error_returns_failure(self) -> None:session = MagicMock()@@ -287,16 +293,6 @@ class TestValidateCredentials:assert ok is Falseassert 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(