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 enterprise_connections when Enterprise SSO is off (#87748)

Tom Owers84ba3effb7c6
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 da712a63112f..d0cf388a6a79 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
@@ -114,6 +114,12 @@ The secret key starts with `sk_live_`.
# instance. Scoped to this path, not all of api.clerk.com, since 422 elsewhere can mean
# a genuinely bad request that's worth investigating rather than an account limitation.
"422 Client Error: Unprocessable Entity for url: https://api.clerk.com/v1/saml_connections": "SAML connections (Enterprise SSO) aren't available on your Clerk plan or instance. Turn off syncing for this table, or enable SAML connections in your Clerk dashboard.",
+ # Clerk answers 422 feature_requires_email_address_enabled for enterprise_connections when
+ # Enterprise SSO isn't available on the instance. The unfiltered list request is identical
+ # every run, so it re-fails on every schedule; classify it so the schema pauses instead of
+ # retrying. Scoped to this path, mirroring saml_connections, since a 422 elsewhere can be a
+ # genuinely bad request worth investigating rather than an account limitation.
+ "422 Client Error: Unprocessable Entity for url: https://api.clerk.com/v1/enterprise_connections": "Enterprise SSO connections aren't available on your Clerk plan or instance. Turn off syncing for this table, or enable Enterprise SSO in your Clerk dashboard.",
# Clerk's list api_keys endpoint requires a subject (a user or organization id), so the
# unfiltered list request we send is rejected with a 400 every run. Scoped to this path,
# not all of api.clerk.com, since a 400 elsewhere can be a genuinely bad request worth
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 20248000d04f..ed9c8e959c06 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
@@ -31,6 +31,8 @@ class TestClerkSource:
"401 Client Error: Unauthorized for url: https://api.clerk.com/v1/users?limit=100",
# `saml_connections` endpoint, SAML/Enterprise SSO not available on the account's plan.
"422 Client Error: Unprocessable Entity for url: https://api.clerk.com/v1/saml_connections?limit=100",
+ # `enterprise_connections` endpoint, Enterprise SSO not available on the account's instance.
+ "422 Client Error: Unprocessable Entity for url: https://api.clerk.com/v1/enterprise_connections?limit=100 | api error: code=feature_requires_email_address_enabled",
# `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.