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(warehouse_sources): say what to do when the account picker needs admin (#96701)

Tom Owers4bb90b732709
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_source.py b/products/warehouse_sources/backend/presentation/views/external_data_source.py
index d309908c4079..2ba8e4a3144c 100644
--- a/products/warehouse_sources/backend/presentation/views/external_data_source.py
+++ b/products/warehouse_sources/backend/presentation/views/external_data_source.py
@@ -1990,6 +1990,19 @@ class IntegrationAccountsResponseSerializer(serializers.Serializer):
)
+class AccountPickerManagementPermission(TeamMemberAdminManagementPermission):
+ """Admin gate for the account picker, with a message the customer can act on.
+
+ The base message names no next step. Free entry stays open on the account field, so a
+ member who cannot list accounts can still finish the source by filling the account in.
+ """
+
+ message = (
+ "You need admin access to this project to list the accounts this connection can reach. "
+ "Ask an admin to finish the setup, or fill in the account yourself."
+ )
+
+
@dataclasses.dataclass(frozen=True, kw_only=True, slots=True)
class ResolvedStoredCredential:
payload: dict = dataclasses.field(repr=False)
@@ -2095,7 +2108,7 @@ class ExternalDataSourceViewSet(TeamAndOrgViewSetMixin, AccessControlViewSetMixi
APIScopePermission(),
AccessControlPermission(),
TeamMemberAccessPermission(),
- TeamMemberAdminManagementPermission(),
+ AccountPickerManagementPermission(),
]
raise NotImplementedError()
diff --git a/products/warehouse_sources/backend/tests/api/test_external_data_source.py b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
index 75b4bc19503b..bbe3b05a0371 100644
--- a/products/warehouse_sources/backend/tests/api/test_external_data_source.py
+++ b/products/warehouse_sources/backend/tests/api/test_external_data_source.py
@@ -12640,6 +12640,7 @@ class TestOAuthAccountsEndpoint(APIBaseTest):
response = self.client.get(self._url("GoogleSearchConsole", integration.id))
assert response.status_code == status.HTTP_403_FORBIDDEN, response.content
+ assert "fill in the account yourself" in response.json()["detail"]
def test_missing_params_returns_400(self):
response = self.client.get(