: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(data-imports): keep a source rollout window out of error tracking (#106875)
Tom Owers1e8ce81a5e75
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py b/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.pyindex 736aa7fa28aa..63fb9df018a0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/common/base.py@@ -479,11 +479,21 @@ class _BaseSource(ABC, Generic[ConfigType]):return None+class SourceExtractionNotImplementedError(NotImplementedError):+ """A source class carries no `source_for_pipeline` of its own, so only the base stub is left.++ Reaching this in a sync means the worker runs an older build than the web code that created+ the source: a scaffolded source is only connectable once its implementation ships. Kept+ distinct from a plain `NotImplementedError`, which a source implementation raises for a real+ defect the pipeline must keep reporting.+ """++class SimpleSource(_BaseSource[ConfigType], Generic[ConfigType]):"""Base class for sources with standard pipeline creation."""def source_for_pipeline(self, config: ConfigType, inputs: SourceInputs) -> SourceResponse:- raise NotImplementedError()+ raise SourceExtractionNotImplementedError(f"{type(self).__name__} does not implement source_for_pipeline")class ResumableSource(_BaseSource[ConfigType], Generic[ConfigType, ResumableData]):@@ -492,7 +502,7 @@ class ResumableSource(_BaseSource[ConfigType], Generic[ConfigType, ResumableDatadef source_for_pipeline(self, config: ConfigType, resumable_source_manager: ResumableSourceManager[ResumableData], inputs: SourceInputs) -> SourceResponse:- raise NotImplementedError()+ raise SourceExtractionNotImplementedError(f"{type(self).__name__} does not implement source_for_pipeline")@abstractmethoddef get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[ResumableData]:diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.pyindex 792c42f29b54..7903c77bed59 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py@@ -63,6 +63,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.basAnySource,ResumableSource,SimpleSource,+ SourceExtractionNotImplementedError,error_message_matches,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.byte_bounded_extraction_flag import (@@ -624,6 +625,16 @@ async def _import_data_with_reporting(inputs: ImportDataActivityInputs, logger:consumer_manages_job_status=True,skip_post_import_activities=True,)+ except SourceExtractionNotImplementedError as e:+ # Web refuses to create a source whose implementation it does not have, so the+ # stub is only reachable while this worker still runs the build from before the+ # source shipped. Temporal's retry picks up a caught-up worker, so keep retrying+ # and keep a rollout window out of error tracking.+ await logger.awarning(+ "Source extraction is not implemented in this build, leaving retry to Temporal",+ source_type=source_type,+ )+ raise NonReportableError(SOURCE_ROLLOUT_IN_PROGRESS_MESSAGE) from eexcept Exception as e:# Some sources connect to the remote during setup rather than lazily during# the run — e.g. for a `mongodb+srv://` URI pymongo resolves the SRV DNS@@ -683,6 +694,13 @@ INTEGRATION_CREDENTIAL_UNAVAILABLE_MESSAGE = ()+# What a customer reads while a newly shipped source is still rolling out across the workers.+SOURCE_ROLLOUT_IN_PROGRESS_MESSAGE = (+ "Support for this source is still rolling out. This sync will retry automatically, and no "+ "action is needed on your side."+)++# What a customer reads when a lookup against PostHog's own app DB fails. It deliberately repeats# none of the driver wording: the workflow hands whatever message escapes an activity to the# finalization activity, which substring-matches it against every source's non-retryable patterns,diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.pyindex b726e6b44bf9..812787f3a469 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py@@ -34,7 +34,10 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core impfrom products.warehouse_sources.backend.temporal.data_imports.pipelines.core.arrow_utils import (SchemaColumnTypeChangedException,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import SimpleSource+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (+ SimpleSource,+ SourceExtractionNotImplementedError,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import TemporaryHostResolutionErrorfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client import (RESTClientNonRetryableError,@@ -180,6 +183,40 @@ async def test_retryable_setup_error_is_reraised():handle_mock.assert_not_awaited()+async def test_unimplemented_source_extraction_is_retryable_and_unreported():+ # A scaffolded source is only connectable once its implementation ships, so a worker that+ # still holds the base stub is running the build from before that release. The next retry+ # lands on a caught-up worker, so the run must stay retryable, must not disable the schema,+ # and must not mint an error-tracking issue for a rollout window.+ error = SourceExtractionNotImplementedError("DepotSource does not implement source_for_pipeline")+ source = _make_source(error, {})++ with _patched_activity(source) as handle_mock:+ with pytest.raises(NonReportableError) as exc_info:+ await import_data_activity_sync(_inputs())++ assert exc_info.value.__cause__ is error+ assert str(exc_info.value) == module.SOURCE_ROLLOUT_IN_PROGRESS_MESSAGE+ handle_mock.assert_not_awaited()+++async def test_plain_not_implemented_error_from_a_source_is_still_reported():+ # Source implementations raise NotImplementedError for real defects — an unbound resolve param+ # in a REST manifest, or the Postgres guard against building a pipeline off the base template.+ # Only the base stub means "this build is behind", so a plain one must still escape raw.+ error = NotImplementedError("Resource orders defines resolve params that are not bound in path")+ source = _make_source(error, {})++ with _patched_activity(source) as handle_mock:+ with pytest.raises(NotImplementedError) as exc_info:+ await import_data_activity_sync(_inputs())++ assert exc_info.value is error+ handle_mock.assert_not_awaited()++@pytest.mark.asyncioasync def test_unparseable_config_routes_through_handler():# A corrupt / double-encoded stored config makes parse_config raise deterministically before