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 reporting transient App Store Connect 5xx/429 as unhandled errors (#82378)

Tom Owers5d1662684f3f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/source.py
index 4bd23a2b1945..91ea1f7fedd1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/source.py
@@ -121,10 +121,17 @@ Sales and subscription reports also need your vendor number (App Store Connect
def get_retryable_errors(self) -> set[str]:
# `_get` has no retry loop of its own — it relies on the tracked session's urllib3 adapter
- # to retry a connection failure or read timeout. Once that budget is exhausted, Temporal
- # retries the whole activity, so this is transient and self-recovering. The host is fixed
- # (never user input), so matching on it doesn't risk swallowing an unrelated failure.
- return {"HTTPSConnectionPool(host='api.appstoreconnect.apple.com'"}
+ # to retry a connection failure, read timeout, or 429/5xx response. Once that budget is
+ # exhausted, Temporal retries the whole activity, so this is transient and self-recovering.
+ # The host is fixed (never user input), so matching on it doesn't risk swallowing an
+ # unrelated failure. `requests.Response.raise_for_status` derives "Server Error"/"Client
+ # Error" prefixes from the status code alone, not the vendor's reason text, so they're
+ # stable to match on (see mailchimp/convex sources for the same pattern).
+ return {
+ "HTTPSConnectionPool(host='api.appstoreconnect.apple.com'",
+ "Server Error",
+ "429 Client Error",
+ }
def get_schemas(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/tests/test_app_store_connect_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/tests/test_app_store_connect_source.py
index 1469d1cc7c38..8dc9b24350c6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/tests/test_app_store_connect_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/app_store_connect/tests/test_app_store_connect_source.py
@@ -217,6 +217,14 @@ class TestAppStoreConnectSource:
"read_timeout",
"HTTPSConnectionPool(host='api.appstoreconnect.apple.com', port=443): Read timed out. (read timeout=60)",
),
+ (
+ "server_error",
+ "500 Server Error: Internal Server Error for url: https://api.appstoreconnect.apple.com/v1/salesReports?filter%5Bfrequency%5D=DAILY",
+ ),
+ (
+ "rate_limited",
+ "429 Client Error: Too Many Requests for url: https://api.appstoreconnect.apple.com/v1/salesReports",
+ ),
]
)
def test_retryable_errors_match_transient_network_failures(self, _name: str, observed_error: str) -> None: