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(plausible): stop retrying a payment-required rejection (#107270)

Tom Owers96b8af889af4
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/source.py
index af26c70803f3..386bcb73056b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/source.py
@@ -52,6 +52,10 @@ class PlausibleSource(ResumableSource[PlausibleSourceConfig, PlausibleResumeConf
return {
"401 Client Error": "Your Plausible API key is invalid or has been revoked. Create a new key in your Plausible account settings, then reconnect.",
"403 Client Error": "Your Plausible API key is missing the stats read scope needed to sync this data. Grant it in your Plausible account settings, then reconnect.",
+ # Plausible answers 402 when the site's subscription has lapsed or its plan doesn't
+ # include the stats API. The billing state is fixed until the customer changes it, so
+ # every retry replays the same rejection. Match the status text, not the self-hosted URL.
+ "402 Client Error": "Your Plausible plan doesn't include API access, or its subscription has lapsed. Update the subscription in your Plausible account, then reconnect.",
# Plausible rejects the query as malformed for this site (a permanent 400 — auth and
# missing-site cases are 401/403/404 and handled above). Retrying resends the same
# request, so stop. Match the status text, not the self-hosted URL, which varies.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/tests/test_plausible_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/tests/test_plausible_source.py
index 3dd3f732244b..295e4b53cebc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/tests/test_plausible_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/plausible/tests/test_plausible_source.py
@@ -61,6 +61,9 @@ class TestSourceConfig:
[
# A 400 is a permanent rejection from Plausible for this site.
("400 Client Error: Bad Request for url: https://plausible.io/api/v2/query", "400 Client Error"),
+ # A 402 means the site's subscription lapsed or its plan has no stats API; retrying
+ # re-hits the same billing state.
+ ("402 Client Error: Payment Required for url: https://plausible.io/api/v2/query", "402 Client Error"),
# A self-hosted Host that doesn't resolve via DNS is raised from source_for_pipeline's
# host validation; retrying replays the same check, so it must stop.
(