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(data-imports): stop retrying checkout.com reports 401 auth failures (#78957)

Tom Owerseb7ea9658178
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/source.py
index 637eb3d328b8..07a0faee579c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/source.py
@@ -110,6 +110,12 @@ class CheckoutComSource(ResumableSource[CheckoutComSourceConfig, CheckoutComResu
errors[f"403 Client Error: Forbidden for url: {host}/reports"] = (
"Checkout.com denied access to reports. Please check that your access key has the reports scope."
)
+ # Unlike disputes, a freshly-minted token still gets 401 (not 403) from the
+ # reports endpoint when the access key lacks the reports scope, so a mid-sync
+ # re-mint (which handles a genuinely expired token elsewhere) never resolves it.
+ errors[f"401 Client Error: Unauthorized for url: {host}/reports"] = (
+ "Checkout.com denied access to reports. Please check that your access key has the reports scope."
+ )
errors[f"403 Client Error: Forbidden for url: {host}/payments/search"] = (
"Checkout.com denied access to payments search. Please check that your access key has the payments scope."
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/tests/test_checkout_com_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/tests/test_checkout_com_source.py
index c036c1d93fc7..8777edd796b9 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/tests/test_checkout_com_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/checkout_com/tests/test_checkout_com_source.py
@@ -68,6 +68,10 @@ class TestCheckoutComSource:
"403 Client Error: Forbidden for url: https://api.checkout.com/disputes?limit=250",
"403 Client Error: Forbidden for url: https://api.checkout.com/reports?limit=100",
"403 Client Error: Forbidden for url: https://api.sandbox.checkout.com/reports/rpt_1/files/file_1",
+ # A freshly-minted token still gets 401 (not 403) from reports when the access
+ # key lacks the reports scope, so a mid-sync re-mint never resolves it.
+ "401 Client Error: Unauthorized for url: https://api.checkout.com/reports?limit=100",
+ "401 Client Error: Unauthorized for url: https://api.sandbox.checkout.com/reports/rpt_1/files/file_1",
],
)
def test_non_retryable_errors_match_auth_failures(self, observed_error):