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.

test(data-imports): guard post-maintenance file listing before S3 prep (#74658)

Tom Owersfe6ca668bdc0
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
index fa751109a537..9c0ccc5f6c12 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py
@@ -173,6 +173,22 @@ class TestRunPostLoadDeltaMaintenance:
else:
update_config.assert_not_called()
+ @parameterized.expand([("non_cdc", False), ("cdc", True)])
+ @pytest.mark.asyncio
+ async def test_prepares_s3_files_with_post_maintenance_file_list(self, _name: str, is_cdc: bool) -> None:
+ # Compaction/vacuum maintenance above can rewrite or delete files referenced by the
+ # pre-maintenance file_uris snapshot the caller passed in. Regression: prepare_s3_files_for_querying
+ # was called with that stale snapshot, raising FileNotFoundError on files maintenance just removed.
+ schema = _make_schema(is_cdc=is_cdc)
+ post_maintenance_uris = ["s3://bucket/orders/compacted.parquet"]
+ helper = _make_helper(file_uris=post_maintenance_uris)
+
+ _, prepare_s3 = await _run_post_load(schema, helper, cdc_write_mode="incremental" if is_cdc else None)
+
+ prepare_s3.assert_awaited_once()
+ assert prepare_s3.await_args is not None
+ assert prepare_s3.await_args.args[2] == post_maintenance_uris
+
@parameterized.expand(
[
# A genuine maintenance bug must still be captured for visibility.