: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(warehouse-sources): stop retrying Stripe syncs that use a publishable key (#83373)
Tom Owersc93e53f2f364
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/source.pyindex 425c1b415656..2fc7dc5e2b98 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/source.py@@ -289,6 +289,10 @@ If automatic creation failed with a permissions error, the fix depends on how yo# / 'plan_read'). The customer must add the scope in Stripe — retrying won't help. Surface# Stripe's raw message (None) since it names the exact scope to enable."does not have the required permissions for this endpoint": None,+ # The customer pasted a publishable key (pk_...) instead of a secret/restricted key.+ # Publishable keys can't authenticate any of the read endpoints we sync, so every retry+ # fails identically — match Stripe's stable rejection text (the request id varies).+ "This API call cannot be made with a publishable API key": "Your Stripe API key is a publishable key, which cannot be used to sync data. Please use a secret or restricted key instead, then reconnect.",# A non-Connect key was sent with a `stripe_account` header (the source's "Account id"),# so Stripe rejects the whole request for the account rather than a specific scope."Only Stripe Connect platforms can work with other accounts": "Stripe rejected the request because your API key isn't authorized for the configured Stripe account. The 'Account id' in your source settings only applies to Stripe Connect platform accounts — remove or correct it if your key belongs directly to the account, then reconnect.",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.pyindex d994910587bb..9b7fb8aeb12e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/stripe/tests/test_stripe_source.py@@ -226,6 +226,9 @@ class TestStripeSource:# account_invalid: key not authorized for the configured account, or revoked app access.# Raised mid-sync as stripe.PermissionError, matched on the stable phrase (key/account redacted)."The provided key 'sk_test_***qPsl' does not have access to account 'stripe_s***less' (or that account does not exist). Application access may have been revoked.",+ # A publishable key was used where a secret/restricted key is required — matched on the+ # stable message text, ignoring the request id prefix.+ "Request req_abc123: This API call cannot be made with a publishable API key. Please use a secret API key. You can find a list of your API keys at https://dashboard.stripe.com/account/apikeys.",],)def test_non_retryable_errors_match_permission_failures(self, observed_error):