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(whop): stop retrying a request Whop rejects as invalid (#95977)

Tom Owers213890724b89
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/source.py
index 47d2dae0993f..00256b6f72bd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/source.py
@@ -145,6 +145,15 @@ class WhopSource(
"Your Whop API key does not have permission to read this resource. Grant the missing read "
"permission in your Whop dashboard and reconnect."
),
+ # Whop answers `code=bad_request` when it refuses the list query this source builds for a
+ # table. The query is derived from the endpoint catalog and the connected company, so every
+ # run reissues the identical request and re-fails. Whop reports a missing permission as 403
+ # and an overload as 429/5xx, so a 400 is never a transient blip. Without this the schema
+ # keeps its schedule and burns a job on every run while showing the raw HTTP error.
+ "400 Client Error: Bad Request for url: https://api.whop.com": (
+ "Whop rejected the request for this table, so it can't sync. Turn off syncing for this "
+ "table, then re-enable the sync."
+ ),
}
def get_canonical_descriptions(self) -> CanonicalDescriptions:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/tests/test_whop_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/tests/test_whop_source.py
index 7ac22f935866..c339e47099bc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/whop/tests/test_whop_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/whop/tests/test_whop_source.py
@@ -3,6 +3,7 @@ from unittest import mock
from posthog.schema import ReleaseStatus
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.whop import WhopSourceConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.whop.settings import (
ALL_WEBHOOK_EVENTS,
@@ -48,6 +49,21 @@ class TestWhopSource:
# duplicate; only a merge on `id` dedupes them.
assert schema.supports_append is (endpoint in INCREMENTAL_ENDPOINTS and endpoint not in MERGE_ONLY_ENDPOINTS)
+ @pytest.mark.parametrize(
+ "observed_error,non_retryable",
+ [
+ (
+ "400 Client Error: Bad Request for url: https://api.whop.com/api/v1/payments"
+ "?first=100&company_id=biz_example | api error: code=bad_request",
+ True,
+ ),
+ ("429 Client Error: Too Many Requests for url: https://api.whop.com/api/v1/payments", False),
+ ("503 Server Error: Service Unavailable for url: https://api.whop.com/api/v1/payments", False),
+ ],
+ )
+ def test_a_rejected_request_stops_the_sync_and_an_overload_does_not(self, observed_error, non_retryable):
+ assert error_message_matches(observed_error, self.source.get_non_retryable_errors()) is non_retryable
+
def test_canonical_descriptions_only_describe_real_schemas(self):
# A key that doesn't match a schema name is silently ignored, so the descriptions would
# never reach the table they were written for.