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(clerk): stop retrying a deterministic redirect_urls 404 every sync (#87435)

Tom Owers234a71a386c6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
index 29430eaa93e5..da712a63112f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/source.py
@@ -119,6 +119,12 @@ The secret key starts with `sk_live_`.
# not all of api.clerk.com, since a 400 elsewhere can be a genuinely bad request worth
# investigating rather than an endpoint that can't be listed.
"400 Client Error: Bad Request for url: https://api.clerk.com/v1/api_keys": "The API keys table can't be synced from Clerk. Turn off syncing for this table.",
+ # Clerk answers 404 resource_not_found for redirect_urls on instances/plans where the
+ # resource isn't available. The request is identical every run, so it re-fails on every
+ # schedule; classify it so the schema is paused instead of burning a job each time. Scoped
+ # to this path, not all of api.clerk.com, since a 404 elsewhere can be a genuinely missing
+ # record worth investigating rather than an account limitation.
+ "404 Client Error: Not Found for url: https://api.clerk.com/v1/redirect_urls": "The redirect URLs table isn't available on your Clerk plan or instance. Turn off syncing for this table.",
**{reason: reason for reason in RETIRED_ENDPOINTS.values()},
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk_source.py
index e013e618f96d..fdd67f5bf91f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk_source.py
@@ -55,6 +55,8 @@ class TestClerkSource:
"422 Client Error: Unprocessable Entity for url: https://api.clerk.com/v1/saml_connections?limit=100",
# `api_keys` endpoint, which Clerk rejects without a subject param on the list request.
"400 Client Error: Bad Request for url: https://api.clerk.com/v1/api_keys?limit=100",
+ # `redirect_urls` endpoint, not available on the account's Clerk plan or instance.
+ "404 Client Error: Not Found for url: https://api.clerk.com/v1/redirect_urls?limit=100 | api error: code=resource_not_found",
],
)
def test_non_retryable_errors_matches_observed_error_message(self, observed_error):
@@ -81,6 +83,14 @@ class TestClerkSource:
assert not any(key in other_vendor_error for key in non_retryable_errors)
+ def test_non_retryable_errors_does_not_match_404_on_other_clerk_endpoints(self):
+ # A 404 from a different endpoint may be a genuinely missing record worth investigating, not
+ # the redirect_urls account limitation — the match must stay scoped to `redirect_urls`.
+ other_endpoint_error = "404 Client Error: Not Found for url: https://api.clerk.com/v1/users?limit=100"
+
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in other_endpoint_error for key in non_retryable_errors)
+
def test_non_retryable_errors_does_not_match_422_on_other_clerk_endpoints(self):
# A 422 from a different endpoint is a genuinely bad request worth investigating, not an
# account limitation — the match must stay scoped to `saml_connections`.