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): stop reporting transient object-store blips from the statistics activity (#80077)

Tom Owers2e3d1df0bd8c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py
index 7add583045a2..ad0d5f98c0f2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/compute_table_statistics.py
@@ -30,6 +30,7 @@ from posthog.exceptions_capture import capture_exception
from posthog.models import Team
from posthog.sync import database_sync_to_async
from posthog.temporal.common.base import PostHogWorkflow
+from posthog.temporal.common.errors import NonReportableError
from posthog.temporal.common.heartbeat import LivenessHeartbeater as Heartbeater
from products.warehouse_sources.backend.models.column_statistics import WarehouseColumnStatistics
@@ -281,7 +282,11 @@ async def compute_table_statistics_activity(inputs: ComputeTableStatisticsInputs
inputs.team_id, inputs.schema_id
)
except Exception as e:
- capture_exception(e)
+ # get_delta_table already re-raises known-transient object-store blips as
+ # NonReportableError (see DeltaTableRef._capture_unless_transient) and intentionally
+ # skips reporting them itself — don't undo that here.
+ if not isinstance(e, NonReportableError):
+ capture_exception(e)
try:
posthoganalytics.capture(
distinct_id=f"team-{inputs.team_id}",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_compute_table_statistics.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_compute_table_statistics.py
index 731370ec82c2..f860b5277db2 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_compute_table_statistics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_compute_table_statistics.py
@@ -21,6 +21,9 @@ from products.warehouse_sources.backend.models.external_data_job import External
from products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchema
from products.warehouse_sources.backend.models.external_data_source import ExternalDataSource
from products.warehouse_sources.backend.models.table import DataWarehouseTable
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ TransientObjectStoreError,
+)
from products.warehouse_sources.backend.temporal.data_imports.workflow_activities import (
compute_table_statistics as comp,
)
@@ -307,10 +310,30 @@ class TestComputeTableStatisticsActivity:
mock_sync.assert_called_once()
async def test_activity_reraises_on_failure(self) -> None:
- with patch.object(comp, "compute_table_statistics_sync", side_effect=ValueError("boom")):
+ with (
+ patch.object(comp, "compute_table_statistics_sync", side_effect=ValueError("boom")),
+ patch.object(comp, "capture_exception") as mock_capture,
+ ):
inputs = ComputeTableStatisticsInputs(team_id=1, schema_id=uuid.uuid4())
with pytest.raises(ValueError, match="boom"):
await ActivityEnvironment().run(compute_table_statistics_activity, inputs)
+ mock_capture.assert_called_once()
+
+ async def test_activity_does_not_report_transient_object_store_error(self) -> None:
+ # get_delta_table re-raises known-transient object-store blips (S3 connect timeouts, IMDS/STS
+ # credential hiccups) as TransientObjectStoreError specifically so they don't mint a fresh
+ # error-tracking issue per blip. The activity's own except block must respect that contract
+ # instead of unconditionally calling capture_exception on every exception.
+ with (
+ patch.object(
+ comp, "compute_table_statistics_sync", side_effect=TransientObjectStoreError("connect timeout")
+ ),
+ patch.object(comp, "capture_exception") as mock_capture,
+ ):
+ inputs = ComputeTableStatisticsInputs(team_id=1, schema_id=uuid.uuid4())
+ with pytest.raises(TransientObjectStoreError):
+ await ActivityEnvironment().run(compute_table_statistics_activity, inputs)
+ mock_capture.assert_not_called()
class TestComputeTableStatisticsWorkflow: