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 S3 blips from pre-extraction repartition detection (#75845)

Tom Owers29d1da16d8f8
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
index 4de381c6c83f..a4b8931fbf96 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
@@ -31,7 +31,10 @@ from posthog.temporal.common.utils import retry_on_db_connection_drop
from products.warehouse_sources.backend.models.external_data_job import ExternalDataJob
from products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchema
-from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta_table_helper import DeltaTableHelper
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta_table_helper import (
+ DeltaTableHelper,
+ is_transient_object_store_error,
+)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition import (
RepartitionSupersededError,
RepartitionTarget,
@@ -159,9 +162,15 @@ def _maybe_flag_pre_extraction(
return None
async_to_sync(maybe_flag_for_repartition)(schema, schema.source, job, delta_table, logger, enabled=enabled)
except Exception as e:
- # Detection is best-effort; a failure here must not block the sync.
- logger.warning("repartition: pre-extraction detection failed", exc_info=True)
- capture_exception(e)
+ # Detection is best-effort; a failure here must not block the sync. `get_delta_table` re-raises
+ # transient object-store blips (S3/credential-provider timeouts) rather than swallowing them —
+ # see its own docstring — so this is the layer that must apply is_transient_object_store_error
+ # before reporting, same as the other best-effort call sites around this table.
+ if is_transient_object_store_error(e):
+ logger.warning("repartition: pre-extraction detection failed with a transient object-store error")
+ else:
+ logger.warning("repartition: pre-extraction detection failed", exc_info=True)
+ capture_exception(e)
return None
return schema.repartition_pending
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
index e2a846bba280..679d3a569bdc 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
@@ -3,8 +3,11 @@ import uuid
import pytest
from unittest.mock import AsyncMock, MagicMock, patch
+from parameterized import parameterized
+
from products.warehouse_sources.backend.temporal.data_imports.workflow_activities.repartition_table import (
RepartitionActivityInputs,
+ _maybe_flag_pre_extraction,
_maybe_repartition_table,
)
@@ -83,3 +86,48 @@ class TestRepartitionActivityDeltaFolder:
assert await_args is not None
assert await_args.kwargs["helper"] is mock_helper_cls.return_value
assert mock_job_model.objects.get.call_args.kwargs == {"id": JOB_ID}
+
+
+class TestMaybeFlagPreExtraction:
+ @parameterized.expand(
+ [
+ (
+ "generic_s3_error",
+ OSError(
+ "Generic S3 error: Error getting list response body: HTTP error: "
+ "request or response body error: operation timed out"
+ ),
+ ),
+ (
+ "credential_provider_timeout",
+ OSError(
+ "Operation not supported: an error occurred while loading credentials: "
+ "dispatch failure: timeout: client error (Connect): HTTP connect timeout occurred: timed out"
+ ),
+ ),
+ ]
+ )
+ @patch(f"{MODULE}.capture_exception")
+ def test_transient_object_store_error_is_not_reported(
+ self, _name: str, error: OSError, mock_capture: MagicMock
+ ) -> None:
+ schema = _schema(name="stripe_charge", s3_folder_name=None)
+ helper = MagicMock()
+ helper.get_delta_table = AsyncMock(side_effect=error)
+
+ result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock(), enabled=True)
+
+ assert result is None
+ mock_capture.assert_not_called()
+
+ @patch(f"{MODULE}.capture_exception")
+ def test_non_transient_error_is_still_reported(self, mock_capture: MagicMock) -> None:
+ schema = _schema(name="stripe_charge", s3_folder_name=None)
+ helper = MagicMock()
+ error = ValueError("unexpected schema drift")
+ helper.get_delta_table = AsyncMock(side_effect=error)
+
+ result = _maybe_flag_pre_extraction(schema, MagicMock(), helper, MagicMock(), enabled=True)
+
+ assert result is None
+ mock_capture.assert_called_once_with(error)