: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
chore(data-warehouse): add regression test for vitally empty-results paginator guard (#61161)
posthog[bot]fcc1ad3c56bf
diff --git a/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py b/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.pyindex 2176af4e32cc..84198cb13221 100644--- a/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py+++ b/posthog/temporal/data_imports/sources/vitally/tests/test_vitally.py@@ -6,6 +6,7 @@ from unittest.mock import MagicMock, Mock, patchfrom posthog.temporal.data_imports.sources.vitally.settings import CUSTOM_OBJECT_SCHEMA_PREFIXfrom posthog.temporal.data_imports.sources.vitally.source import VitallySourcefrom posthog.temporal.data_imports.sources.vitally.vitally import (+ VitallyPaginator,get_custom_object_records_resource,list_custom_object_definitions,vitally_source,@@ -44,6 +45,38 @@ OPPORTUNITY_DEFINITION = {}+class TestVitallyPaginator:+ @pytest.mark.parametrize(+ "body,start_value,expected_has_next,expected_cursor",+ [+ pytest.param({}, "1970-01-01", False, None, id="falsy_body_stops"),+ # Regression: an empty results page must not IndexError, it must cleanly end pagination.+ pytest.param({"results": [], "next": "cursor-2"}, "1970-01-01", False, None, id="empty_results_stops"),+ pytest.param(+ {"results": [{"updatedAt": "2026-01-02T00:00:00Z"}], "next": "cursor-2"},+ "1970-01-01",+ True,+ "cursor-2",+ id="newer_page_continues",+ ),+ pytest.param(+ {"results": [{"updatedAt": "1970-01-01T00:00:00Z"}], "next": "cursor-2"},+ "2026-01-01",+ False,+ None,+ id="older_than_start_stops",+ ),+ ],+ )+ def test_incremental_update_state(self, body, start_value, expected_has_next, expected_cursor) -> None:+ paginator = VitallyPaginator(incremental_start_value=start_value, should_use_incremental_field=True)++ paginator.update_state(_make_response(body))++ assert paginator._has_next_page is expected_has_next+ assert paginator._cursor == expected_cursor++class TestListCustomObjectDefinitions:@pytest.mark.parametrize("pages,expected_defs,expected_call_count",