: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-modeling): list dag schedules client-side, not by WorkflowType (#61442)
andrew j. mcgeheebd57bb97ce5e
diff --git a/products/data_modeling/backend/schedule.py b/products/data_modeling/backend/schedule.pyindex 50ba5f509a7f..ade5fd0b55a5 100644--- a/products/data_modeling/backend/schedule.py+++ b/products/data_modeling/backend/schedule.py@@ -41,10 +41,10 @@ async def get_v2_scheduled_dag_ids() -> set[str]:"""temporal = await async_connect()dag_ids: set[str] = set()- # Pre-filter server-side so we don't page through every v1 `data-modeling-run` schedule;- # keep the client-side check as a safety net since visibility data is eventually consistent.- query = f"WorkflowType = '{DATA_MODELING_EXECUTE_DAG_WORKFLOW}'"- async for listing in await temporal.list_schedules(query=query):+ # The schedule visibility store does not support filtering on WorkflowType (it raises+ # "cannot filter on WorkflowType"), unlike workflow visibility. So we list all schedules and+ # filter client-side on the action's workflow type.+ async for listing in await temporal.list_schedules():action = listing.schedule.action if listing.schedule else Noneif (isinstance(action, ScheduleListActionStartWorkflow)diff --git a/products/data_modeling/backend/test/test_schedule.py b/products/data_modeling/backend/test/test_schedule.pyindex 73ec0b480a70..66d7e91a0de3 100644--- a/products/data_modeling/backend/test/test_schedule.py+++ b/products/data_modeling/backend/test/test_schedule.py@@ -6,7 +6,7 @@ import pytestfrom posthog.test.base import BaseTestfrom unittest import mock-from temporalio.client import ScheduleCalendarSpec+from temporalio.client import ScheduleCalendarSpec, ScheduleListActionStartWorkflowfrom products.data_modeling.backend.models import Nodefrom products.data_modeling.backend.models.dag import DAG@@ -16,6 +16,7 @@ from products.data_modeling.backend.schedule import (_deterministic_int,build_schedule_spec,get_v2_saved_query_ids,+ get_v2_scheduled_dag_ids,partition_saved_queries_by_v2_schedule,)@@ -307,3 +308,40 @@ class TestV2ScheduleGuard(BaseTest):eligible, on_v2 = partition_saved_queries_by_v2_schedule([])assert eligible == []assert on_v2 == []+++class TestGetV2ScheduledDagIds:+ def _listing(self, schedule_id: str, workflow: str):+ action = mock.Mock(spec=ScheduleListActionStartWorkflow, workflow=workflow)+ return mock.Mock(id=schedule_id, schedule=mock.Mock(action=action))++ def test_lists_client_side_without_workflowtype_query(self):+ captured: dict = {}+ listings = [+ self._listing("dag-on-v2", "data-modeling-execute-dag"),+ self._listing("sq-on-v1", "data-modeling-run"),+ ]++ async def fake_list_schedules(*args, **kwargs):+ captured["args"] = args+ captured["kwargs"] = kwargs++ async def gen():+ for listing in listings:+ yield listing++ return gen()++ temporal = mock.Mock()+ temporal.list_schedules = fake_list_schedules+ with mock.patch(+ "products.data_modeling.backend.schedule.async_connect",+ new=mock.AsyncMock(return_value=temporal),+ ):+ result = get_v2_scheduled_dag_ids()++ # The schedule visibility store rejects filtering on WorkflowType, so we must not pass a+ # server-side query and must filter the listings client-side instead.+ assert captured["args"] == ()+ assert "query" not in captured["kwargs"]+ assert result == {"dag-on-v2"}