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 failing the invitations sync on a 404 not-found (#90793)

Tom Owers433ea139225a
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 dbff5e7be85a..d8d5d7239323 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
@@ -42,7 +42,15 @@ CLERK_ENDPOINTS: dict[str, ClerkEndpointConfig] = {
"organization_memberships": ClerkEndpointConfig(
name="organization_memberships", path="/organization_memberships", is_wrapped_response=True
),
- "invitations": ClerkEndpointConfig(name="invitations", path="/invitations"),
+ "invitations": ClerkEndpointConfig(
+ name="invitations",
+ path="/invitations",
+ # Clerk answers 404 resource_not_found for the invitations list on instances where the
+ # resource isn't available — the same feature-off signal the domains and OAuth applications
+ # endpoints give. A 404 can't coexist with real data (that returns 200 with an array), so
+ # skip zero rows instead of failing the schema every run.
+ gated_feature="Invitations",
+ ),
"sessions": ClerkEndpointConfig(
name="sessions",
path="/sessions",
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 a16d6f7be516..4140eabd8b2c 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
@@ -526,6 +526,8 @@ class TestClerkFeatureGatedEndpoints:
("domains", 404, {"errors": [{"code": "resource_not_found"}]}),
# Organizations off: the invitations list answers the same 404 resource_not_found.
("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"}]}),
],
)
def test_feature_not_enabled_syncs_no_rows_instead_of_failing(