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(data-warehouse): explain that sentry organization tokens can't sync data (#124093)

Tom Owers77374c4096cd
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
index a9395ec06708..794c9b75ff6f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/sentry.py
@@ -1278,6 +1278,15 @@ def validate_credentials(
"Copy the token again from Sentry, then reconnect.",
)
+ # Organization tokens carry a fixed CI-only scope that can't be widened, so the generic
+ # "missing scopes" advice below would send the user to create another token that fails the same way.
+ if auth_token.strip().startswith("sntrys_"):
+ return (
+ False,
+ "This is a Sentry organization token, which can't read your Sentry data. "
+ "Create a personal token with these scopes, then reconnect: " + ", ".join(REQUIRED_SENTRY_SCOPES) + ".",
+ )
+
headers = _auth_headers(auth_token)
try:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
index cc74260baa48..2c36b7ab4ff8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/sentry/tests/test_sentry.py
@@ -304,6 +304,18 @@ class TestSentryTransport:
assert error.startswith("Invalid Sentry auth token")
assert network.requests_log == []
+ def test_validate_credentials_rejects_organization_token_with_personal_token_guidance(self) -> None:
+ with scripted_network([]) as network:
+ valid, error = validate_credentials(auth_token="sntrys_fake-org-token", organization_slug="acme")
+
+ assert not valid
+ assert error is not None
+ assert error.startswith("This is a Sentry organization token")
+ assert "Create a personal token" in error
+ for scope in REQUIRED_SENTRY_SCOPES:
+ assert scope in error
+ assert network.requests_log == []
+
def test_validate_credentials_403_names_required_scopes(self) -> None:
with scripted_network(always(ScriptedResponse(status=403))):
valid, error = validate_credentials(auth_token="token", organization_slug="acme")