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): document the settings.modules.READ scope the credential probe requires (#78477)

Kyle Swankdd9ce847581d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/source.py
index 208d594034e7..1f6ef97dd7b6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/source.py
@@ -59,7 +59,7 @@ class ZohoCRMSource(ResumableSource[ZohoCRMSourceConfig, ZohoCRMResumeConfig]):
# variant too, or the same credential rejection retries the whole activity budget.
"400 Client Error: for url: https://accounts.zoho": "Zoho CRM rejected your OAuth credentials. Check that the client ID, client secret, and refresh token all belong to the same self client.",
"401 Client Error: Unauthorized for url": "Your Zoho CRM access token is invalid or expired. Reconnect the source to issue a new one.",
- "403 Client Error: Forbidden for url": "Your Zoho CRM token is missing a scope for this module. Re-authorize with the ZohoCRM.modules.ALL and ZohoCRM.settings.fields.READ scopes.",
+ "403 Client Error: Forbidden for url": "Your Zoho CRM token is missing a scope for this module. Re-authorize with the ZohoCRM.modules.ALL, ZohoCRM.settings.fields.READ, and ZohoCRM.settings.modules.READ scopes.",
}
@property
@@ -72,7 +72,7 @@ class ZohoCRMSource(ResumableSource[ZohoCRMSourceConfig, ZohoCRMResumeConfig]):
releaseStatus=ReleaseStatus.ALPHA,
caption="""Connect your Zoho CRM account to pull leads, contacts, deals, and your other modules into the PostHog Data warehouse.
-In the [Zoho API console](https://api-console.zoho.com), create a **Self Client** and generate a refresh token for the scopes `ZohoCRM.modules.ALL` and `ZohoCRM.settings.fields.READ`. Paste the client ID, client secret, and refresh token below, then pick the data center your Zoho account lives in.""",
+In the [Zoho API console](https://api-console.zoho.com), create a **Self Client** and generate a refresh token for the scopes `ZohoCRM.modules.ALL`, `ZohoCRM.settings.fields.READ`, and `ZohoCRM.settings.modules.READ`. Paste the client ID, client secret, and refresh token below, then pick the data center your Zoho account lives in.""",
iconPath="/static/services/zoho_crm.png",
docsUrl="https://posthog.com/docs/cdp/sources/zoho-crm",
fields=cast(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/tests/test_zoho_crm_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/tests/test_zoho_crm_source.py
index 758a423b0239..85e5b1626cc8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/tests/test_zoho_crm_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/zoho_crm/tests/test_zoho_crm_source.py
@@ -90,6 +90,28 @@ class TestZohoCRMSource:
assert self.source.default_version == "v8"
assert self.source.api_docs_url.startswith("https://")
+ def test_source_config_documents_scopes_the_requests_require(self) -> None:
+ # `settings.modules.READ` is the easy one to drop, because nothing in the sync path uses it:
+ # it exists only so `validate_credentials` can probe /settings/modules. Zoho answers that
+ # probe with a 401 OAUTH_SCOPE_MISMATCH when the scope is missing, and the blanket
+ # `except Exception` in `validate_credentials` flattens it to "Invalid Zoho CRM credentials"
+ # — so leaving it out of the caption fails every setup that followed the caption exactly.
+ # The caption is also the docs page: posthog.com builds /docs/cdp/sources/zoho-crm from it
+ # via /api/public_source_configs, so this string is the only place the scopes are published.
+ required_scopes = [
+ "ZohoCRM.modules.ALL",
+ "ZohoCRM.settings.fields.READ",
+ "ZohoCRM.settings.modules.READ",
+ ]
+ caption = self.source.get_source_config.caption
+ forbidden_message = self.source.get_non_retryable_errors()["403 Client Error: Forbidden for url"]
+
+ 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
+
@pytest.mark.parametrize(
"observed_error",
[