: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(langfuse): keep exhausted read-timeout errors out of error tracking (#83632)
Tom Owers779c8277f7b9
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.pyindex 7da948db14fa..6a360e1d606c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py@@ -128,6 +128,20 @@ Find your project API keys in your Langfuse **Project settings > API Keys**. SetREPEATED_CURSOR_ERROR: "The Langfuse host repeated a pagination cursor, so the sync was stopped to avoid looping. Check that the host points at a real Langfuse instance.",}+ def get_retryable_errors(self) -> set[str]:+ # `get_rows`'s tenacity retry already retries a 429/422/5xx (the "Langfuse API error+ # (retryable)" sentinel), a dropped connection, and a read timeout up to MAX_RETRIES. Once+ # that budget exhausts, urllib3 wraps the failure as "Max retries exceeded with url" (with+ # the read timeout nested inside as its cause), and Temporal retries the whole activity from+ # the saved pagination checkpoint, so the failure is transient and self-recovering. The host+ # is customer-controlled (self-hosted Langfuse), so match only the stable, host-independent+ # parts of the message.+ return {+ "Langfuse API error (retryable)",+ "Read timed out",+ "Max retries exceeded with url",+ }+def get_schemas(self,config: LangfuseSourceConfig,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.pyindex 02667b1d2256..6a603916e821 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py@@ -71,6 +71,25 @@ class TestLangfuseSource:def test_non_retryable_errors(self, expected_key):assert expected_key in self.source.get_non_retryable_errors()+ @pytest.mark.parametrize(+ "expected_pattern", ["Langfuse API error (retryable)", "Read timed out", "Max retries exceeded with url"]+ )+ def test_retryable_errors(self, expected_pattern):+ assert expected_pattern in self.source.get_retryable_errors()++ def test_exhausted_connection_pool_error_is_classified_retryable(self):+ # Matches the message urllib3 raises once `get_rows`'s tenacity retry (which covers read+ # timeouts and connection failures, not just 429/422/5xx) exhausts its budget — keeps this+ # transient, self-recovering failure out of error tracking instead of reaching+ # `logger.aexception`.+ observed_error = (+ "HTTPSConnectionPool(host='us.cloud.langfuse.com', port=443): Max retries exceeded with "+ "url: /api/public/traces?limit=50&orderBy=timestamp.asc&page=5339 (Caused by "+ "ReadTimeoutError(\"HTTPSConnectionPool(host='us.cloud.langfuse.com', port=443): "+ 'Read timed out. (read timeout=60)"))'+ )+ assert any(pattern in observed_error for pattern in self.source.get_retryable_errors())+def test_get_schemas_returns_all_endpoints(self):schemas = self.source.get_schemas(self.config, self.team_id)assert {s.name for s in schemas} == set(ENDPOINTS)