: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(clerk): stop retrying the unlistable api_keys table (#79530)
Tom Owers72bed949a48e
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.pyindex 41e5a1207961..29430eaa93e5 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,11 @@ 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'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+ # investigating rather than an endpoint that can't be listed.+ "400 Client Error: Bad Request for url: https://api.clerk.com/v1/api_keys": "The API keys table can't be synced from Clerk. 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.pyindex 524ccc2cacf5..e013e618f96d 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@@ -53,12 +53,22 @@ 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",+ # `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",],)def test_non_retryable_errors_matches_observed_error_message(self, observed_error):non_retryable_errors = self.source.get_non_retryable_errors()assert any(key in observed_error for key in non_retryable_errors)+ def test_non_retryable_errors_does_not_match_400_on_other_clerk_endpoints(self):+ # A 400 from a different endpoint is a genuinely bad request worth investigating, not the+ # known api_keys limitation — the match must stay scoped to `api_keys`.+ other_endpoint_error = "400 Client Error: Bad Request for url: https://api.clerk.com/v1/users?limit=100"++ non_retryable_errors = self.source.get_non_retryable_errors()+ assert not any(key in other_endpoint_error for key in non_retryable_errors)+@pytest.mark.parametrize("other_vendor_error",[