: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): allow plans fetch before installation exists (#62819)
Matt Brookerdb4c15bf9533
diff --git a/ee/api/vercel/test/test_vercel_installation.py b/ee/api/vercel/test/test_vercel_installation.pyindex 6eb92140e869..f5fa14b9c5ee 100644--- a/ee/api/vercel/test/test_vercel_installation.py+++ b/ee/api/vercel/test/test_vercel_installation.py@@ -61,6 +61,16 @@ class TestVercelInstallationAPI(VercelTestBase):assert response.status_code == status.HTTP_200_OKmock_plans.assert_called_once()+ @patch("ee.vercel.integration.VercelIntegration.get_vercel_plans")+ def test_plans_allows_placeholder_installation_id(self, mock_plans):+ # Vercel fetches plans before an installation exists, using the literal+ # path segment "new" instead of a real installation ID.+ mock_plans.return_value = [{"id": "free"}, {"id": "paid"}]+ response = self._request("get", url="/api/vercel/v1/installations/new/plans/", auth_type="system")++ assert response.status_code == status.HTTP_200_OK+ mock_plans.assert_called_once()+@patch("ee.vercel.integration.VercelIntegration.update_installation")def test_update_calls_upsert_installation(self, mock_update):response = self._request("patch", data=self.update_payload)diff --git a/ee/api/vercel/vercel_permission.py b/ee/api/vercel/vercel_permission.pyindex 3423345f42ae..a56a1eca7867 100644--- a/ee/api/vercel/vercel_permission.py+++ b/ee/api/vercel/vercel_permission.py@@ -17,6 +17,10 @@ class VercelPermission(BasePermission):ADMIN_ONLY_ACTIONS = {"update", "partial_update", "create", "destroy"}# Actions that allow USER role (read-only operations)READ_ONLY_ACTIONS = {"list", "retrieve", "plans"}+ # Actions that serve static, non-tenant data. Vercel calls plans before an+ # installation exists, with the literal path segment "new" in place of an+ # installation ID, so the token-to-installation binding cannot apply.+ INSTALLATION_MATCH_EXEMPT_ACTIONS = {"plans"}def has_permission(self, request: Request, view) -> bool:self._validate_auth_type_allowed(request, view)@@ -28,7 +32,9 @@ class VercelPermission(BasePermission):# Bind the token to its own installation. These viewsets resolve their target by# the URL installation_id without calling check_object_permissions, so the match# must be enforced here for every installation-scoped endpoint.- if "installation_id" in view.kwargs or "parent_lookup_installation_id" in view.kwargs:+ if (+ "installation_id" in view.kwargs or "parent_lookup_installation_id" in view.kwargs+ ) and view.action not in self.INSTALLATION_MATCH_EXEMPT_ACTIONS:self._validate_installation_id_match(request, view)return True