: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(plain): document user:read and label:read scopes required by queries (#69715)
Tom Owers59e01ff905eb
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.pyindex c1c3ce1b5268..31b8406a3e18 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/source.py@@ -55,6 +55,8 @@ Make sure to grant the following read permissions:- customer:read- thread:read- timeline:read+- user:read+- label:read""",iconPath="/static/services/plain.png",fields=cast(@@ -82,7 +84,10 @@ Make sure to grant the following read permissions:def get_non_retryable_errors(self) -> dict[str, str | None]:return {"401 Client Error": "Invalid Plain credentials. Please check your API key.",- "403 Client Error": "Access forbidden. Your API key may lack required permissions.",+ # Plain fails the whole GraphQL request when the key lacks a scope any requested field needs.+ # Our customers/threads queries read assignee (user:read) and label (label:read) data on top+ # of the basics, so name every required scope — retrying a key missing one never succeeds.+ "403 Client Error": "Access forbidden. Grant your Plain API key these read permissions, then reconnect: customer:read, thread:read, timeline:read, user:read, label:read.",}def get_schemas(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain_source.pyindex 45740072430a..898b61768412 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plain/tests/test_plain_source.py@@ -38,6 +38,19 @@ class TestPlainSource:assert "401 Client Error" in errorsassert "403 Client Error" in errors+ def test_source_config_documents_scopes_the_queries_require(self):+ # The customers/threads queries read assignee (user:read) and label (label:read) data, and Plain+ # 403s the whole request when the key lacks a scope any requested field needs. Keep the setup+ # caption and the forbidden-error guidance in sync with what the queries actually fetch.+ required_scopes = ["customer:read", "thread:read", "timeline:read", "user:read", "label:read"]+ caption = self.source.get_source_config.caption+ forbidden_message = self.source.get_non_retryable_errors()["403 Client Error"]+ assert caption is not None+ assert forbidden_message is not None+ for scope in required_scopes:+ assert scope in caption+ assert scope in forbidden_message+def test_get_schemas(self):schemas = self.source.get_schemas(self.config, self.team_id)