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(decagon): stop reporting exhausted read-timeout retries as tracked exceptions (#84194)

Tom Owersd6ea4bdfb982
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py
index e5adbedc0c6a..ce4feb84b803 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/source.py
@@ -86,6 +86,17 @@ You can find your API key on the **Developer** page of the [Decagon dashboard](h
),
}
+ def get_retryable_errors(self) -> set[str]:
+ # `fetch_page` (decagon.py) already retries `DecagonRetryableError` (429/5xx),
+ # `requests.ReadTimeout`, and `requests.ConnectionError` with backoff; if that budget
+ # still exhausts, Temporal retries the whole activity, so the failure is transient and
+ # self-recovering. Match the host rather than the per-endpoint path, so a timeout or
+ # dropped connection on any Decagon endpoint is covered.
+ return {
+ "HTTPSConnectionPool(host='api.decagon.ai', port=443)",
+ "Decagon API error (retryable)",
+ }
+
def get_schemas(
self,
config: DecagonSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py
index 34c75b74822d..59f6e018d9dc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py
@@ -7,6 +7,7 @@ from parameterized import parameterized
from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import error_message_matches
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.decagon.decagon import DecagonResumeConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.decagon.settings import ENDPOINTS
@@ -115,6 +116,26 @@ class TestDecagonSource:
assert "401 Client Error: Unauthorized" in errors
assert "403 Client Error: Forbidden" in errors
+ @parameterized.expand(
+ [
+ (
+ "connection_error_wrapping_read_timeout",
+ "HTTPSConnectionPool(host='api.decagon.ai', port=443): Max retries exceeded with url: "
+ "/conversation/export (Caused by ReadTimeoutError(\"HTTPSConnectionPool(host='api.decagon.ai', "
+ 'port=443): Read timed out. (read timeout=60)"))',
+ ),
+ (
+ "exhausted_retryable_status",
+ "Decagon API error (retryable): status=503, url=https://api.decagon.ai/tag/all",
+ ),
+ ]
+ )
+ def test_retryable_errors_cover_exhausted_transient_failures(self, _name: str, error_msg: str) -> None:
+ # fetch_page already retries these with backoff; once that budget exhausts they must
+ # stay classified as retryable (self-recovering via Temporal) rather than tracked
+ # exception noise.
+ assert error_message_matches(error_msg, self.source.get_retryable_errors())
+
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.decagon.source.validate_decagon_credentials"
)