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(revenuecat): name the scope missing when webhook registration is denied (#95237)

Tom Owersc4bff1a65d1a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/revenuecat.py b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/revenuecat.py
index 79a9ff837a7f..91b93287f5ee 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/revenuecat.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/revenuecat.py
@@ -470,7 +470,18 @@ def create_webhook(
response.raise_for_status()
except requests.HTTPError as e:
logger.warning("Failed to register RevenueCat webhook integration", error=str(e))
- return WebhookCreationResult(success=False, error=_format_http_error(e))
+ return WebhookCreationResult(
+ success=False,
+ error=_format_http_error(
+ e,
+ # The read-only hint the validate path passes doesn't fit here: registering the
+ # integration needs write scope, and the failure screen offers manual setup.
+ forbidden_hint=(
+ "The v2 secret API key is missing write access. Give it write permission for "
+ "integrations, or follow the manual setup below."
+ ),
+ ),
+ )
except requests.RequestException as e:
logger.warning("Could not reach RevenueCat to register webhook", error=str(e))
return WebhookCreationResult(success=False, error=f"Could not reach RevenueCat: {e}")
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/tests/test_revenuecat.py b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/tests/test_revenuecat.py
index 287204bf470a..854f26de9f2a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/tests/test_revenuecat.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/revenuecat/tests/test_revenuecat.py
@@ -500,6 +500,10 @@ class TestCreateWebhook:
# Webhook creation needs write scope, so this shared 403 message must not tell the user to
# grant read access (unlike the credential-check path).
assert "read" not in result.error.lower()
+ # Naming the scope is the point: a scope-neutral 403 sends people round re-checking a key
+ # that was never missing the permission they looked at.
+ assert "write permission for integrations" in result.error
+ assert "manual setup" in result.error
class TestDeleteWebhook: