: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(vercel): surface a clear error for unexpected token validation responses (#75881)
Tom Owers1811faf36889
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/tests/test_vercel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/tests/test_vercel.pyindex f1c8943cc92a..e7df0f69bc26 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/tests/test_vercel.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/tests/test_vercel.py@@ -135,6 +135,19 @@ class TestValidateCredentials:assert ok is Falseassert error == "boom"+ def test_unexpected_status_does_not_leak_raw_status_code(self) -> None:+ response = requests.Response()+ response.status_code = 404+ session = MagicMock()+ session.get.return_value = response+ with patch.object(vercel, "make_tracked_session", lambda *a, **k: session):+ ok, error = validate_credentials("token")++ assert ok is False+ assert error is not None+ assert "Vercel API error" not in error+ assert "404" not in error+class TestGetRows:def test_full_refresh_follows_until_cursor_across_pages(self, monkeypatch: Any) -> None:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/vercel.py b/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/vercel.pyindex 1344440641f6..70c4be9eeb22 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/vercel.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/vercel/vercel.py@@ -136,7 +136,10 @@ def validate_credentials(access_token: str) -> tuple[bool, str | None]:return True, Noneif response.status_code in (401, 403):return False, "Invalid or unauthorized Vercel access token"- return False, f"Vercel API error: {response.status_code}"+ return (+ False,+ "Couldn't validate your Vercel access token. Check that it's a valid token from your Vercel account settings, then try again.",+ )def get_rows(