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): skip the sms templates table when SMS isn't enabled (#99791)

Tom Owers1298f1933a61
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/settings.py
index d8d5d7239323..11ac8835e522 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/settings.py
@@ -127,7 +127,14 @@ CLERK_ENDPOINTS: dict[str, ClerkEndpointConfig] = {
"redirect_urls": ClerkEndpointConfig(name="redirect_urls", path="/redirect_urls"),
"jwt_templates": ClerkEndpointConfig(name="jwt_templates", path="/jwt_templates"),
"email_templates": ClerkEndpointConfig(name="email_templates", path="/templates/email"),
- "sms_templates": ClerkEndpointConfig(name="sms_templates", path="/templates/sms"),
+ "sms_templates": ClerkEndpointConfig(
+ name="sms_templates",
+ path="/templates/sms",
+ # Clerk answers 404 resource_not_found for the SMS template list on instances that don't
+ # have SMS switched on — the same feature-off signal the domains and OAuth applications
+ # endpoints give. Skip zero rows instead of failing the schema every run.
+ gated_feature="SMS",
+ ),
"commerce_plans": ClerkEndpointConfig(
name="commerce_plans",
# Clerk renamed this from /commerce/plans to /billing/plans; the old path now answers 400.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk.py b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk.py
index e16029793e9f..70d2f0a3900b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/clerk/tests/test_clerk.py
@@ -528,6 +528,8 @@ class TestClerkFeatureGatedEndpoints:
("organization_invitations", 404, {"errors": [{"code": "resource_not_found"}]}),
# Invitations unavailable: the list answers the same 404 resource_not_found.
("invitations", 404, {"errors": [{"code": "resource_not_found"}]}),
+ # SMS off: the SMS template list answers the same 404 resource_not_found.
+ ("sms_templates", 404, {"errors": [{"code": "resource_not_found"}]}),
],
)
def test_feature_not_enabled_syncs_no_rows_instead_of_failing(