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 JWT templates list the instance won't serve (#100878)

Tom Owersde56e7f72150
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 d0cf388a6a79..6e691fca3d3b 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
@@ -131,6 +131,12 @@ The secret key starts with `sk_live_`.
# 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.",
+ # Clerk answers the same 404 resource_not_found for jwt_templates on instances/plans
+ # that don't serve the resource. An instance that does serve it returns 200 with an
+ # empty array when no template exists, so the 404 can't mean "none configured". The
+ # unfiltered list request is identical every run, so it re-fails on every schedule.
+ # Scoped to this path for the same reason as redirect_urls above.
+ "404 Client Error: Not Found for url: https://api.clerk.com/v1/jwt_templates": "The JWT templates 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 ed9c8e959c06..73cadd69feec 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
@@ -37,6 +37,8 @@ class TestClerkSource:
"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",
+ # `jwt_templates` endpoint, not available on the account's Clerk plan or instance.
+ "404 Client Error: Not Found for url: https://api.clerk.com/v1/jwt_templates?limit=100 | api error: code=resource_not_found",
],
)
def test_non_retryable_errors_matches_observed_error_message(self, observed_error):