: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): treat a 404 from credential validation as an invalid token (#107714)
Tom Owers4fc5a196d3bd
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 baa7fd9e0f9d..af692c558880 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@@ -194,7 +194,7 @@ class TestValidateCredentials:# A transient Vercel-side error must not tell the user to fix their (possibly valid) token.assert "Check that it's a valid token" not in (error or "")- @parameterized.expand([(400,), (401,)])+ @parameterized.expand([(400,), (401,), (404,)])def test_credential_rejection_status_tells_the_user_to_replace_the_token(self, status: int) -> None:response = requests.Response()response.status_code = statusdiff --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 5d39609cd37b..a891d7f95be4 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@@ -181,10 +181,13 @@ def validate_credentials(access_token: str) -> tuple[bool, str | None]:if response.status_code == 200:return True, None- if response.status_code in (400, 401):+ if response.status_code in (400, 401, 404):# The probe carries no query string and no body, so a 400 is Vercel rejecting the token# itself rather than anything we sent — a token pasted with stray characters reads as- # malformed at the gateway before it is ever looked up.+ # malformed at the gateway before it is ever looked up. A 404 here isn't documented for+ # this endpoint, but is observed when the token doesn't resolve to a Vercel user at all+ # (e.g. a team-scoped token used where an account access token is expected); the fix is+ # the same as an invalid token, so it shares the message.return False, _VERCEL_INVALID_TOKEN_ERRORif response.status_code == 403:return (