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(data-imports): keep transient S3 blips out of error tracking at the activity boundary (#76352)

Tom Owersb088a8148732
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py
index c050a360070d..d3f93c9721d5 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py
@@ -3,6 +3,8 @@ from django.db import InterfaceError, OperationalError
import botocore.exceptions
import deltalake.exceptions
+from posthog.temporal.common.errors import NonReportableError
+
# Substrings of the object-store errors raised talking to our own S3-backed data-warehouse bucket
# that are transient and self-recovering, not a bug in our code or a customer credential problem:
# - the first three come from delta-rs's Rust `object_store` crate inside `DeltaTable.is_deltatable()`
@@ -19,6 +21,16 @@ TRANSIENT_OBJECT_STORE_ERRORS = (
)
+class TransientObjectStoreError(NonReportableError):
+ """A known-transient object-store blip (see is_transient_object_store_error), re-raised as this
+ type instead of the original OSError/DeltaError. Skipping the inline capture_exception call
+ alone isn't enough: the raw error still escapes the activity uncaught and reaches the Temporal
+ activity interceptor (posthog/temporal/common/posthog_client.py), which reports every activity
+ exception to error tracking unless it's a NonReportableError — so it minted a fresh issue per
+ blip anyway. Wrapping keeps it out of tracking at that boundary too. Temporal's retry policy is
+ unaffected either way, since NonReportableError only suppresses reporting, not retries."""
+
+
def is_transient_object_store_error(error: BaseException) -> bool:
"""True for a transient object-store error, however it happened to surface.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py
index 1c2512967588..b5a468df1300 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta_table_helper.py
@@ -17,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.arr
conditional_lru_cache_async,
)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ TransientObjectStoreError,
is_transient_object_store_error,
)
@@ -155,13 +156,16 @@ class DeltaTableHelper:
async def _capture_unless_transient(self, e: Exception) -> None:
"""capture_exception unless `e` is a known-transient object-store blip (see
is_transient_object_store_error) — those recover on retry and aren't a defect, so reporting
- them to error tracking is just noise. Never suppresses the re-raise itself, so Temporal's
- activity retry policy is unaffected either way.
+ them to error tracking is just noise. A transient blip is re-raised as
+ TransientObjectStoreError instead of letting the original propagate: the activity
+ interceptor reports any uncaught activity exception unless it's a NonReportableError, so a
+ bare re-raise here would still mint a fresh issue at that boundary. Never suppresses the
+ re-raise itself, so Temporal's activity retry policy is unaffected either way.
"""
if is_transient_object_store_error(e):
await self._logger.awarning(f"get_delta_table: transient object-store error, not reporting: {e}")
- else:
- capture_exception(e)
+ raise TransientObjectStoreError(str(e)) from e
+ capture_exception(e)
@conditional_lru_cache_async(maxsize=1, condition=lambda result: result is not None)
async def get_delta_table(self) -> deltalake.DeltaTable | None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py
index 9034326ea6a8..f744eb1f5cfb 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test/test_delta_table_helper.py
@@ -10,6 +10,9 @@ import deltalake
from parameterized import parameterized
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.arrow_utils import realign_decimal_buffers
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ TransientObjectStoreError,
+)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta_table_helper import DeltaTableHelper
_HELPER_MODULE = "products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta_table_helper"
@@ -166,25 +169,31 @@ class TestGetDeltaTableUnrecoverableErrors:
@pytest.mark.asyncio
async def test_is_deltatable_transient_error_is_not_captured_but_still_reraised(self):
"""A known-transient object-store blip (e.g. an S3 LIST request timing out) must not be
- reported to error tracking as a defect — it's a self-recovering network hiccup, not a bug —
- but it must still propagate so Temporal's activity retry policy retries the sync."""
+ reported to error tracking as a defect — it's a self-recovering network hiccup, not a bug.
+ It must still propagate (as TransientObjectStoreError, not the raw OSError) so Temporal's
+ activity retry policy retries the sync. Wrapping matters, not just suppressing the inline
+ capture_exception call here: a bare OSError would still reach the activity interceptor
+ (posthog_client.py), which reports any uncaught activity exception that isn't a
+ NonReportableError, minting a fresh error-tracking issue per blip anyway."""
helper = DeltaTableHelper(resource_name="t", job=MagicMock(), logger=_make_logger())
delta_uri = "s3://bucket/team_id/job_id/t"
module = "products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta_table_helper"
+ original_error = OSError(
+ "Generic S3 error\nError getting list response body\nHTTP error\n"
+ "request or response body error\noperation timed out"
+ )
with (
patch.object(helper, "_get_delta_table_uri", AsyncMock(return_value=delta_uri)),
patch(f"{module}.deltalake.DeltaTable") as mock_delta_table,
patch(f"{module}.capture_exception") as mock_capture,
):
- mock_delta_table.is_deltatable.side_effect = OSError(
- "Generic S3 error\nError getting list response body\nHTTP error\n"
- "request or response body error\noperation timed out"
- )
+ mock_delta_table.is_deltatable.side_effect = original_error
- with pytest.raises(OSError, match="operation timed out"):
+ with pytest.raises(TransientObjectStoreError, match="operation timed out") as exc_info:
await helper.get_delta_table()
+ assert exc_info.value.__cause__ is original_error
mock_capture.assert_not_called()
cast(AsyncMock, helper._logger.awarning).assert_awaited_once()
assert helper.is_first_sync is False