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(shopify): stop retrying a store address that no longer answers (#100061)

Tom Owers24174a8d19b8
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
index b42d9b83cd99..db568e49af21 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/shopify.py
@@ -134,6 +134,13 @@ SHOPIFY_PAYMENT_REQUIRED_ERROR_MESSAGE = (
"the import will resume."
)
+# 404 from the Admin API GraphQL endpoint itself (as opposed to the OAuth token endpoint above) —
+# Shopify serves no Admin API at a subdomain with no live store behind it, so the store closed or
+# was renamed after the source was connected. Retrying can't bring it back, so
+# `ShopifySource.get_non_retryable_errors` matches on the stable status text (not the per-store URL)
+# to fail the job fast, with the same copy the token endpoint's 404 uses.
+SHOPIFY_GRAPHQL_NOT_FOUND_ERROR_MATCH = "404 Client Error: Not Found"
+
# 401 from the Admin API GraphQL endpoint itself (as opposed to the OAuth token endpoint
# above) — the token was accepted when minted but is no longer valid for the store, e.g. the
# app was uninstalled or the token revoked mid-sync. Re-minting on retry can't fix that, so
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
index f0a50c395d27..dcf44dd0a82a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/source.py
@@ -41,6 +41,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.shopify.sh
SHOPIFY_ACCESS_TOKEN_SHOP_NOT_PERMITTED_ERROR,
SHOPIFY_ACCESS_TOKEN_UNSUPPORTED_GRANT_ERROR,
SHOPIFY_GRAPHQL_ACCESS_DENIED_ERROR,
+ SHOPIFY_GRAPHQL_NOT_FOUND_ERROR_MATCH,
SHOPIFY_GRAPHQL_UNAUTHORIZED_ERROR_MATCH,
SHOPIFY_GRAPHQL_UNAUTHORIZED_ERROR_MESSAGE,
SHOPIFY_MISSING_CREDENTIALS_ERROR,
@@ -118,6 +119,10 @@ class ShopifySource(ResumableSource[ShopifySourceConfig, ShopifyResumeConfig]):
# time but Shopify now rejects it. Retrying cannot recover; the user must
# reconnect their integration.
SHOPIFY_GRAPHQL_UNAUTHORIZED_ERROR_MATCH: SHOPIFY_GRAPHQL_UNAUTHORIZED_ERROR_MESSAGE,
+ # 404 from the Admin API GraphQL endpoint — no live store answers at the configured
+ # address. Retrying cannot recover; the user must correct the store id, the same fix
+ # as the token endpoint's 404 above.
+ SHOPIFY_GRAPHQL_NOT_FOUND_ERROR_MATCH: SHOPIFY_STORE_NOT_FOUND_ERROR,
}
def get_retryable_errors(self) -> set[str]:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_non_retryable_errors.py b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_non_retryable_errors.py
index dda72fe32204..ddbb758a83bc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_non_retryable_errors.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/shopify/tests/test_non_retryable_errors.py
@@ -46,6 +46,22 @@ def test_transient_graphql_errors_stay_retryable(error_message):
)
+ "status_code,reason",
+ [
+ (404, "Not Found"),
+ ],
+)
+def test_admin_api_store_not_found_is_non_retryable(status_code, reason):
+ # No live store answers at the configured address, so every retry re-reads the same 404 and
+ # the raw message hands the user back their own store URL instead of the fix.
+ error_message = _http_error_message(status_code, reason)
+ patterns = ShopifySource().get_non_retryable_errors()
+ assert any(pattern in error_message for pattern in patterns), (
+ f"store-not-found error '{error_message}' should match a non-retryable pattern"
+ )
+
+
@pytest.mark.parametrize(
"status_code,reason",
[