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): gate organization invitations so a feature-off 404 skips (#90014)

Tom Owers569209bcf40e
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 fcfd3029cbbe..dbff5e7be85a 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
@@ -49,7 +49,13 @@ CLERK_ENDPOINTS: dict[str, ClerkEndpointConfig] = {
fan_out=ClerkFanOut(parent="users", parent_field="id", query_param="user_id"),
),
"organization_invitations": ClerkEndpointConfig(
- name="organization_invitations", path="/organization_invitations", is_wrapped_response=True
+ name="organization_invitations",
+ path="/organization_invitations",
+ is_wrapped_response=True,
+ # Clerk answers 404 resource_not_found for the organization invitations list on instances
+ # that don't have Organizations 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="Organizations",
),
"organization_domains": ClerkEndpointConfig(
name="organization_domains", path="/organization_domains", is_wrapped_response=True
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 13c5a17f146b..a16d6f7be516 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
@@ -524,6 +524,8 @@ class TestClerkFeatureGatedEndpoints:
("oauth_applications", 404, {"errors": [{"code": "resource_not_found"}]}),
# Domains feature off: the list endpoint answers the same 404 resource_not_found.
("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"}]}),
],
)
def test_feature_not_enabled_syncs_no_rows_instead_of_failing(