: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(warehouse): unstick schemas stuck reporting Running with no sync (#84493)
estefania1b4c013b76e7
diff --git a/products/warehouse_sources/backend/presentation/views/external_data_schema.py b/products/warehouse_sources/backend/presentation/views/external_data_schema.pyindex 4f54b2e8dafb..acc26417b85e 100644--- a/products/warehouse_sources/backend/presentation/views/external_data_schema.py+++ b/products/warehouse_sources/backend/presentation/views/external_data_schema.py@@ -139,21 +139,23 @@ def _reset_cdc_for_full_resnapshot(instance: ExternalDataSchema) -> None:removes=["cdc_last_log_position", "cdc_deferred_runs"],)instance.initial_sync_complete = False- instance.status = ExternalDataSchema.Status.RUNNING- instance.save(update_fields=["initial_sync_complete", "status", "updated_at"])+ instance.save(update_fields=["initial_sync_complete", "updated_at"])try:trigger_external_data_workflow(instance)except temporalio.service.RPCError as e:+ # Leave the status untouched so the Syncs UI doesn't show RUNNING for a workflow that never+ # started. The sync_type_config mutations stay; the schema's intent is still "do a+ # re-snapshot next run".logger.exception("Could not trigger external data workflow after re-snapshot reset",schema_id=str(instance.id),exc_info=e,)- # Roll the status back so the Syncs UI doesn't show RUNNING for a workflow that never started.- # The sync_type_config mutations stay — the schema's intent is still "do a re-snapshot next run".- instance.status = ExternalDataSchema.Status.FAILED- instance.save(update_fields=["status"])+ return++ instance.status = ExternalDataSchema.Status.RUNNING+ instance.save(update_fields=["status", "updated_at"])# Sync frequencies below the 5-minute floor. No longer accepted as input (dropped from the@@ -1468,6 +1470,19 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):return self.get_paginated_response(LogEntrySerializer(page, many=True).data)return Response(LogEntrySerializer(data, many=True).data)+ @extend_schema(+ request=None,+ responses={+ 200: OpenApiResponse(description="The sync was triggered."),+ 400: OpenApiResponse(+ response={+ "type": "object",+ "properties": {"detail": {"type": "string"}},+ },+ description="The sync could not be started.",+ ),+ },+ )@action(methods=["POST"], detail=True)def reload(self, request: Request, *args: Any, **kwargs: Any):instance: ExternalDataSchema = self.get_object()@@ -1481,8 +1496,13 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):try:trigger_external_data_workflow(instance)except temporalio.service.RPCError as e:+ # Only mark the schema Running once the trigger succeeded: a Running status with no+ # workflow behind it sticks forever (nothing finalizes it) and blocks cancel.logger.exception(f"Could not trigger external data job for schema {instance.id}", exc_info=e)-+ return Response(+ data={"detail": "Couldn't start the sync. Please try again."},+ status=status.HTTP_400_BAD_REQUEST,+ )except Exception as e:logger.exception(f"Could not trigger external data job for schema {instance.id}", exc_info=e)raise@@ -1491,6 +1511,19 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):instance.save()return Response(status=status.HTTP_200_OK)+ @extend_schema(+ request=None,+ responses={+ 200: OpenApiResponse(description="The full resync was triggered."),+ 400: OpenApiResponse(+ response={+ "type": "object",+ "properties": {"detail": {"type": "string"}},+ },+ description="The resync could not be started.",+ ),+ },+ )@action(methods=["POST"], detail=True)def resync(self, request: Request, *args: Any, **kwargs: Any):instance: ExternalDataSchema = self.get_object()@@ -1531,13 +1564,21 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):)if cdc_resync:instance.initial_sync_complete = False- instance.status = ExternalDataSchema.Status.RUNNING- instance.save(update_fields=["status", "updated_at"])try:trigger_external_data_workflow(instance)except temporalio.service.RPCError as e:+ # Only mark the schema Running once the trigger succeeded: a Running status with no+ # workflow behind it sticks forever (nothing finalizes it) and blocks cancel. The+ # sync_type_config reset above stays; the schema's intent is still "resync next run".logger.exception(f"Could not trigger external data job for schema {instance.id}", exc_info=e)+ return Response(+ data={"detail": "Couldn't start the sync. Please try again."},+ status=status.HTTP_400_BAD_REQUEST,+ )++ instance.status = ExternalDataSchema.Status.RUNNING+ instance.save(update_fields=["status", "updated_at"])return Response(status=status.HTTP_200_OK)@@ -1545,8 +1586,14 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):request=None,responses={200: OpenApiResponse(+ response={+ "type": "object",+ "properties": {"detail": {"type": "string"}},+ },description="The running sync was cancelled. v3 pipeline jobs are marked Failed immediately; "- "for older pipeline versions the cancelled workflow records the final status.",+ "for older pipeline versions the cancelled workflow records the final status. When no sync "+ "was actually running but the schema was stuck reporting Running, the schema status is "+ "corrected instead and the response says so.",),400: OpenApiResponse(response={@@ -1568,6 +1615,22 @@ class ExternalDataSchemaViewset(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):)if not latest_running_job or latest_running_job.status != "Running" or not latest_running_job.workflow_id:+ job_is_running = latest_running_job is not None and latest_running_job.status == "Running"+ # A schema reporting Running with no running job is stale (e.g. a trigger that never+ # started a run): nothing will ever repaint it, so the stop button is the user's only+ # way out. Mirror the latest job's terminal status. CDC halted markers absorb status+ # updates (see update_external_job_status), so honor them here too.+ if instance.status == ExternalDataSchema.Status.RUNNING and not job_is_running and not instance.cdc_halted:+ if latest_running_job is not None:+ instance.status = ExternalDataSchema.Status(latest_running_job.status)+ instance.latest_error = latest_running_job.latest_error+ else:+ instance.status = ExternalDataSchema.Status.FAILED+ instance.save(update_fields=["status", "latest_error", "updated_at"])+ return Response(+ data={"detail": "No sync was running. The sync status has been updated."},+ status=status.HTTP_200_OK,+ )return Response(status=status.HTTP_400_BAD_REQUEST,data={"detail": "No running sync to cancel."},diff --git a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.pyindex 14567f3337ae..519bed8380a5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py+++ b/products/warehouse_sources/backend/temporal/data_imports/external_data_job.py@@ -9,6 +9,7 @@ from django.conf import settingsimport posthoganalyticsfrom asgiref.sync import async_to_syncfrom structlog.contextvars import bind_contextvars+from structlog.types import FilteringBoundLoggerfrom temporalio import activity, exceptions, workflowfrom temporalio.client import Clientfrom temporalio.common import RetryPolicy, WorkflowIDReusePolicy@@ -193,6 +194,23 @@ def _customer_facing_error(cause: BaseException | None) -> str:return message or str(cause)+def _fail_stale_running_schema(+ schema_id: str, team_id: int, latest_error: str | None, logger: FilteringBoundLogger+) -> None:+ """Repaint a schema stuck on Running when a run failed without leaving a job to finalize.++ Mirrors `update_external_job_status`: CDC halted markers absorb status updates, so a halted+ schema is left alone.+ """+ schema = ExternalDataSchema.objects.filter(id=schema_id, team_id=team_id).first()+ if schema is None or schema.status != ExternalDataSchema.Status.RUNNING or schema.cdc_halted:+ return+ schema.status = ExternalDataSchema.Status.FAILED+ schema.latest_error = latest_error+ schema.save(update_fields=["status", "latest_error", "updated_at"])+ logger.info("Reset stale Running schema status to Failed", schema_id=schema_id)++@dataclasses.dataclassclass UpdateExternalDataJobStatusInputs:team_id: int@@ -257,11 +275,17 @@ async def update_external_data_job_model(inputs: UpdateExternalDataJobStatusInpujob: ExternalDataJob | None = await database_sync_to_async_pool(_resolve_job)()if job is None:# A FAILED finalization with no resolvable job means an early activity (e.g. create-job)- # failed before a row was committed — nothing is stranded and that failure is already- # reported on its own, so don't double-alarm. A non-FAILED finalization that can't find- # its job is a real anomaly (work we think succeeded has nowhere to record it) — surface it.+ # failed before a row was committed. That failure is already reported on its own, so+ # don't double-alarm. But the schema may have been painted Running by whatever triggered+ # this run, and with no job there is no later finalization to repaint it, so reset it+ # here or it stays stuck on Running forever. A non-FAILED finalization that can't find+ # its job is a real anomaly (work we think succeeded has nowhere to record it): surface it.logger.warning("No job to update status on", workflow_run_id=inputs.workflow_run_id)- if inputs.status != ExternalDataJob.Status.FAILED:+ if inputs.status == ExternalDataJob.Status.FAILED:+ await database_sync_to_async_pool(_fail_stale_running_schema)(+ inputs.schema_id, inputs.team_id, inputs.latest_error, logger+ )+ else:capture_exception(Exception("Data import finalization could not resolve a job to update"))returndiff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.pyindex 01e4f03ce64d..784672aa1e45 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_external_data_job_activities.py@@ -1,5 +1,6 @@import asyncio+import pytestfrom posthog.test.base import BaseTestfrom unittest import mock@@ -9,6 +10,7 @@ from parameterized import parameterizedfrom temporalio.exceptions import ApplicationError, CancelledErrorfrom temporalio.testing import ActivityEnvironment+from posthog.models import Organization, Teamfrom posthog.temporal.utils import ExternalDataWorkflowInputsfrom products.warehouse_sources.backend.models.external_data_job import ExternalDataJob@@ -131,3 +133,46 @@ class TestUpdateExternalDataJobModelActivity(BaseTest):mock_capture_exception.assert_not_called()mock_finish_row_tracking.assert_called_once_with(self.team.id, inputs.schema_id)mock_update_job_status.assert_called_once()+++# transaction=True commits the fixture rows: the activity resolves the schema through+# database_sync_to_async_pool, whose pool-thread connection can't see a test transaction.[email protected]_db(transaction=True)+def test_failed_finalization_with_no_job_resets_stale_running_schema() -> None:+ # When an early activity fails before the job row is committed, no later finalization can+ # repaint the schema, so the Running status painted at trigger time would stick forever.+ org = Organization.objects.create(name="org")+ team = Team.objects.create(organization=org, name="team")+ source = ExternalDataSource.objects.create(team=team)+ schema = ExternalDataSchema.objects.create(+ team=team, source=source, name="table", status=ExternalDataSchema.Status.RUNNING+ )++ env = ActivityEnvironment()+ inputs = UpdateExternalDataJobStatusInputs(+ team_id=team.id,+ job_id=None,+ schema_id=str(schema.id),+ source_id=str(source.id),+ status=ExternalDataJob.Status.FAILED,+ internal_error=None,+ latest_error="could not create the sync job",+ workflow_run_id="run-id-with-no-job",+ )++ with (+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.external_data_job.get_rows",+ return_value=0,+ ),+ mock.patch("products.warehouse_sources.backend.temporal.data_imports.external_data_job.finish_row_tracking"),+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.external_data_job.capture_exception"+ ) as mock_capture_exception,+ ):+ asyncio.run(env.run(update_external_data_job_model, inputs))++ mock_capture_exception.assert_not_called()+ schema.refresh_from_db()+ assert schema.status == ExternalDataSchema.Status.FAILED+ assert schema.latest_error == "could not create the sync job"diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.pyindex 9c3e9e7e3604..37da6bb9dbdf 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/create_job_model.py@@ -233,8 +233,6 @@ def create_external_data_job_model_activity(raise Exception("Source or schema no longer exists - deleted temporal schedule")schema = ExternalDataSchema.objects.get(team_id=inputs.team_id, id=inputs.schema_id)- schema.status = ExternalDataSchema.Status.RUNNING- schema.save()source: ExternalDataSource = schema.source@@ -243,6 +241,10 @@ def create_external_data_job_model_activity(pipeline_version = ExternalDataJob.PipelineVersion.V3_verify_v3_lock_still_held(inputs.team_id, inputs.schema_id)+ # Persist the Running status only after the job row exists: a Running schema with no job+ # behind it can never be finalized, so it would stay stuck on Running forever. With the job+ # committed first, the workflow's finalizer can always resolve it and repaint the schema.+ schema.status = ExternalDataSchema.Status.RUNNINGjob = _create_job(team_id=inputs.team_id,source_id=inputs.source_id,@@ -251,6 +253,7 @@ def create_external_data_job_model_activity(billable=inputs.billable,schema_snapshot=_build_schema_snapshot(schema),)+ schema.save(update_fields=["status", "updated_at"])logger.info(f"Created external data job for external data source {inputs.source_id}",diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.pyindex d2d22c14d22e..568a8d0cb3e8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_create_job_model.py@@ -20,10 +20,12 @@ from products.warehouse_sources.backend.models.external_data_schema import Exterfrom products.warehouse_sources.backend.models.external_data_source import ExternalDataSourcefrom products.warehouse_sources.backend.models.table import DataWarehouseTablefrom products.warehouse_sources.backend.temporal.data_imports.workflow_activities.create_job_model import (+ CreateExternalDataJobModelActivityInputs,_create_job,_enrichment_pending,_statistics_stale,_verify_v3_lock_still_held,+ create_external_data_job_model_activity,)MODULE = "products.warehouse_sources.backend.temporal.data_imports.workflow_activities.create_job_model"@@ -218,3 +220,31 @@ class TestCreateJob:assert ExternalDataJob.objects.filter(schema_id=schema.id).count() == 1assert job.id is not Nonemock_sleep.assert_called_once()+++class TestCreateJobActivityStatusOrdering:+ # The Running status must only be persisted once the job row exists: a Running schema with no+ # job behind it can never be finalized, so it stays stuck on Running forever and blocks cancel.+ @patch(f"{MODULE}.close_old_connections")+ @patch(f"{MODULE}._create_job", side_effect=OperationalError("insert failed"))+ def test_schema_not_left_running_when_job_creation_fails(+ self, _mock_create: MagicMock, _mock_close_connections: MagicMock+ ) -> None:+ team = _team()+ schema = _schema(team, None)+ schema.status = ExternalDataSchema.Status.FAILED+ schema.save()++ inputs = CreateExternalDataJobModelActivityInputs(+ team_id=team.id,+ schema_id=schema.id,+ source_id=schema.source_id,+ billable=True,+ )++ with pytest.raises(OperationalError):+ create_external_data_job_model_activity(inputs)++ schema.refresh_from_db()+ assert schema.status == ExternalDataSchema.Status.FAILEDdiff --git a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py b/products/warehouse_sources/backend/tests/api/test_external_data_schema.pyindex d1654890721c..f006807f3647 100644--- a/products/warehouse_sources/backend/tests/api/test_external_data_schema.py+++ b/products/warehouse_sources/backend/tests/api/test_external_data_schema.py@@ -3107,6 +3107,95 @@ class TestCancelExternalDataSchema(APIBaseTest):assert response.json()["detail"] == "No running sync to cancel."mock_cancel.assert_not_called()+ @parameterized.expand(+ [+ # A trigger that never started a run leaves Running with no job at all.+ ("no_job", None, ExternalDataSchema.Status.FAILED, None),+ # A failed run whose schema repaint was lost leaves Running over a Failed job.+ ("failed_job", "Failed", ExternalDataSchema.Status.FAILED, "the source broke"),+ ("completed_job", "Completed", ExternalDataSchema.Status.COMPLETED, None),+ ]+ )+ @mock.patch(+ "products.warehouse_sources.backend.presentation.views.external_data_schema.cancel_external_data_workflow"+ )+ def test_cancel_corrects_stale_running_schema(+ self, _case, job_status, expected_schema_status, job_error, mock_cancel+ ):+ # A schema stuck reporting Running with no running job used to 400 on cancel, leaving the+ # user no way to clear the stale status. Cancel must correct it instead.+ from products.warehouse_sources.backend.facade.models import ExternalDataJob++ source = ExternalDataSource.objects.create(+ team=self.team, source_type=ExternalDataSourceType.STRIPE, job_inputs={"stripe_secret_key": "123"}+ )+ schema = ExternalDataSchema.objects.create(+ name="BalanceTransaction",+ team=self.team,+ source=source,+ should_sync=True,+ status=ExternalDataSchema.Status.RUNNING,+ sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,+ )+ if job_status is not None:+ ExternalDataJob.objects.create(+ team=self.team,+ pipeline=source,+ schema=schema,+ status=job_status,+ latest_error=job_error,+ workflow_id="test-workflow-id",+ pipeline_version=ExternalDataJob.PipelineVersion.V3,+ )++ response = self.client.post(+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}/cancel/",+ )++ assert response.status_code == 200+ mock_cancel.assert_not_called()++ schema.refresh_from_db()+ assert schema.status == expected_schema_status+ if job_error is not None:+ assert schema.latest_error == job_error+++class TestTriggerFailureDoesNotPaintRunning(APIBaseTest):+ def _create_schema(self):+ source = ExternalDataSource.objects.create(+ team=self.team, source_type=ExternalDataSourceType.STRIPE, job_inputs={"stripe_secret_key": "123"}+ )+ return ExternalDataSchema.objects.create(+ name="BalanceTransaction",+ team=self.team,+ source=source,+ should_sync=True,+ status=ExternalDataSchema.Status.FAILED,+ sync_type=ExternalDataSchema.SyncType.FULL_REFRESH,+ )++ @parameterized.expand([("reload",), ("resync",)])+ @mock.patch(+ "products.warehouse_sources.backend.presentation.views.external_data_schema.trigger_external_data_workflow"+ )+ def test_schema_not_marked_running_when_trigger_fails(self, endpoint, mock_trigger):+ # Painting Running when no workflow started leaves the schema stuck on Running forever+ # (nothing finalizes it) and blocks cancel with "No running sync to cancel."+ from temporalio.service import RPCError++ schema = self._create_schema()+ mock_trigger.side_effect = RPCError("temporal unavailable", RPCStatusCode.UNAVAILABLE, b"")++ response = self.client.post(+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}/{endpoint}/",+ )++ assert response.status_code == 400++ schema.refresh_from_db()+ assert schema.status == ExternalDataSchema.Status.FAILED+class TestExternalDataSchemaAPIKeyScopes(APIBaseTest):def _make_api_key(self, scopes: list[str]) -> str:diff --git a/products/warehouse_sources/frontend/generated/api.schemas.ts b/products/warehouse_sources/frontend/generated/api.schemas.tsindex f1d1260c8510..16e80e517263 100644--- a/products/warehouse_sources/frontend/generated/api.schemas.ts+++ b/products/warehouse_sources/frontend/generated/api.schemas.ts@@ -12812,6 +12812,10 @@ export type ExternalDataSchemasListParams = {search?: string}+export type ExternalDataSchemasCancelCreate200 = {+ detail?: string+}+export type ExternalDataSchemasCancelCreate400 = {detail?: string}@@ -12848,6 +12852,14 @@ export type ExternalDataSchemasLogsRetrieveParams = {search?: string}+export type ExternalDataSchemasReloadCreate400 = {+ detail?: string+}++export type ExternalDataSchemasResyncCreate400 = {+ detail?: string+}+export type ExternalDataSourcesListParams = {/*** Number of results to return per page.diff --git a/products/warehouse_sources/frontend/generated/api.ts b/products/warehouse_sources/frontend/generated/api.tsindex f775019f24ef..8df1c3577a23 100644--- a/products/warehouse_sources/frontend/generated/api.ts+++ b/products/warehouse_sources/frontend/generated/api.ts@@ -14,6 +14,7 @@ import type {DraftCustomManifestRequestApi,DraftCustomManifestResponseApi,ExternalDataSchemaApi,+ ExternalDataSchemasCancelCreate200,ExternalDataSchemasListParams,ExternalDataSchemasLogsRetrieveParams,ExternalDataSourceConnectionOptionApi,@@ -165,8 +166,8 @@ export const externalDataSchemasCancelCreate = async (projectId: string,id: string,options?: RequestInit-): Promise<void> => {- return apiMutator<void>(getExternalDataSchemasCancelCreateUrl(projectId, id), {+): Promise<ExternalDataSchemasCancelCreate200> => {+ return apiMutator<ExternalDataSchemasCancelCreate200>(getExternalDataSchemasCancelCreateUrl(projectId, id), {...options,method: 'POST',})@@ -244,14 +245,11 @@ export const getExternalDataSchemasReloadCreateUrl = (projectId: string, id: strexport const externalDataSchemasReloadCreate = async (projectId: string,id: string,- externalDataSchemaApi?: NonReadonly<ExternalDataSchemaApi>,options?: RequestInit): Promise<void> => {return apiMutator<void>(getExternalDataSchemasReloadCreateUrl(projectId, id), {...options,method: 'POST',- headers: { 'Content-Type': 'application/json', ...options?.headers },- body: JSON.stringify(externalDataSchemaApi),})}@@ -262,14 +260,11 @@ export const getExternalDataSchemasResyncCreateUrl = (projectId: string, id: strexport const externalDataSchemasResyncCreate = async (projectId: string,id: string,- externalDataSchemaApi?: NonReadonly<ExternalDataSchemaApi>,options?: RequestInit): Promise<void> => {return apiMutator<void>(getExternalDataSchemasResyncCreateUrl(projectId, id), {...options,method: 'POST',- headers: { 'Content-Type': 'application/json', ...options?.headers },- body: JSON.stringify(externalDataSchemaApi),})}diff --git a/products/warehouse_sources/frontend/generated/api.zod.ts b/products/warehouse_sources/frontend/generated/api.zod.tsindex 4e78788c6bcb..1b965d6c9b29 100644--- a/products/warehouse_sources/frontend/generated/api.zod.ts+++ b/products/warehouse_sources/frontend/generated/api.zod.ts@@ -312,208 +312,6 @@ export const ExternalDataSchemasIncrementalFieldsCreateBody = /* @__PURE__ */ zo}).describe('A schema of an external data source: its sync configuration and the warehouse table it syncs into.')-export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin = 0-export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax = 5184000--export const externalDataSchemasReloadCreateBodyApiVersionMax = 128--export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod- .object({- should_sync: zod.boolean().optional(),- sync_type: zod- .union([- zod- .enum(['full_refresh', 'incremental', 'append', 'webhook', 'cdc', 'xmin'])- .describe(- '\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- zod.null(),- ])- .optional()- .describe(- 'Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- incremental_field: zod.string().nullish().describe('Column name used to track sync progress.'),- incremental_field_type: zod- .union([- zod- .enum(['integer', 'numeric', 'datetime', 'date', 'timestamp', 'objectid', 'xid'])- .describe(- '\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- zod.null(),- ])- .optional()- .describe(- 'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- incremental_field_lookback_seconds: zod- .number()- .min(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin)- .max(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax)- .nullish()- .describe(- 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'- ),- sync_frequency: zod- .union([- zod- .enum(['never', '5min', '15min', '30min', '1hour', '6hour', '12hour', '24hour', '7day', '30day'])- .describe(- '\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- zod.null(),- ])- .optional()- .describe(- 'How often to sync. The fastest sync frequency is 5 minutes.\n\n\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- sync_time_of_day: zod.iso.time({}).nullish().describe('UTC time of day to run the sync (HH:MM:SS).'),- primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),- cdc_table_mode: zod- .union([- zod- .enum(['consolidated', 'cdc_only', 'both'])- .describe('\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'),- zod.null(),- ])- .optional()- .describe(- 'For CDC syncs: consolidated, cdc_only, or both.\n\n\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'- ),- enabled_columns: zod- .array(zod.string())- .nullish()- .describe(- 'Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here.'- ),- row_filters: zod- .array(- zod.object({- column: zod.string(),- operator: zod.string().describe('One of: > >= < <= = != IN \"NOT IN\".'),- value: zod- .unknown()- .describe(- "Comparison value; must match the column's type. For `IN` \/ `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- ),- })- )- .nullish()- .describe(- "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`\/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`\/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- ),- api_version: zod- .string()- .max(externalDataSchemasReloadCreateBodyApiVersionMax)- .nullish()- .describe(- "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- ),- })- .describe('A schema of an external data source: its sync configuration and the warehouse table it syncs into.')--export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin = 0-export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax = 5184000--export const externalDataSchemasResyncCreateBodyApiVersionMax = 128--export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod- .object({- should_sync: zod.boolean().optional(),- sync_type: zod- .union([- zod- .enum(['full_refresh', 'incremental', 'append', 'webhook', 'cdc', 'xmin'])- .describe(- '\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- zod.null(),- ])- .optional()- .describe(- 'Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- incremental_field: zod.string().nullish().describe('Column name used to track sync progress.'),- incremental_field_type: zod- .union([- zod- .enum(['integer', 'numeric', 'datetime', 'date', 'timestamp', 'objectid', 'xid'])- .describe(- '\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- zod.null(),- ])- .optional()- .describe(- 'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- incremental_field_lookback_seconds: zod- .number()- .min(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin)- .max(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax)- .nullish()- .describe(- 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'- ),- sync_frequency: zod- .union([- zod- .enum(['never', '5min', '15min', '30min', '1hour', '6hour', '12hour', '24hour', '7day', '30day'])- .describe(- '\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- zod.null(),- ])- .optional()- .describe(- 'How often to sync. The fastest sync frequency is 5 minutes.\n\n\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- sync_time_of_day: zod.iso.time({}).nullish().describe('UTC time of day to run the sync (HH:MM:SS).'),- primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),- cdc_table_mode: zod- .union([- zod- .enum(['consolidated', 'cdc_only', 'both'])- .describe('\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'),- zod.null(),- ])- .optional()- .describe(- 'For CDC syncs: consolidated, cdc_only, or both.\n\n\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'- ),- enabled_columns: zod- .array(zod.string())- .nullish()- .describe(- 'Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here.'- ),- row_filters: zod- .array(- zod.object({- column: zod.string(),- operator: zod.string().describe('One of: > >= < <= = != IN \"NOT IN\".'),- value: zod- .unknown()- .describe(- "Comparison value; must match the column's type. For `IN` \/ `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- ),- })- )- .nullish()- .describe(- "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`\/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`\/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- ),- api_version: zod- .string()- .max(externalDataSchemasResyncCreateBodyApiVersionMax)- .nullish()- .describe(- "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- ),- })- .describe('A schema of an external data source: its sync configuration and the warehouse table it syncs into.')-/*** Create, Read, Update and Delete External data Sources.*/diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 411f1cd09cc7..27b3954aaed8 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -87395,6 +87395,10 @@ export namespace Schemas {search?: string;};+ export type ExternalDataSchemasCancelCreate200 = {+ detail?: string;+ };+export type ExternalDataSchemasCancelCreate400 = {detail?: string;};@@ -87431,6 +87435,14 @@ export namespace Schemas {search?: string;};+ export type ExternalDataSchemasReloadCreate400 = {+ detail?: string;+ };++ export type ExternalDataSchemasResyncCreate400 = {+ detail?: string;+ };+export type ExternalDataSourcesListParams = {/*** Number of results to return per page.diff --git a/services/mcp/src/generated/warehouse_sources/api.ts b/services/mcp/src/generated/warehouse_sources/api.tsindex 9624399f515f..7f1954101c9d 100644--- a/services/mcp/src/generated/warehouse_sources/api.ts+++ b/services/mcp/src/generated/warehouse_sources/api.ts@@ -278,107 +278,6 @@ export const ExternalDataSchemasReloadCreateParams = /* @__PURE__ */ zod.object(),})-export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin = 0-export const externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax = 5184000--export const externalDataSchemasReloadCreateBodyApiVersionMax = 128--export const ExternalDataSchemasReloadCreateBody = /* @__PURE__ */ zod- .object({- should_sync: zod.boolean().optional(),- sync_type: zod- .union([- zod- .enum(['full_refresh', 'incremental', 'append', 'webhook', 'cdc', 'xmin'])- .describe(- '\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- zod.null(),- ])- .optional()- .describe(- 'Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- incremental_field: zod.string().nullish().describe('Column name used to track sync progress.'),- incremental_field_type: zod- .union([- zod- .enum(['integer', 'numeric', 'datetime', 'date', 'timestamp', 'objectid', 'xid'])- .describe(- '\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- zod.null(),- ])- .optional()- .describe(- 'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- incremental_field_lookback_seconds: zod- .number()- .min(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMin)- .max(externalDataSchemasReloadCreateBodyIncrementalFieldLookbackSecondsMax)- .nullish()- .describe(- 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'- ),- sync_frequency: zod- .union([- zod- .enum(['never', '5min', '15min', '30min', '1hour', '6hour', '12hour', '24hour', '7day', '30day'])- .describe(- '\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- zod.null(),- ])- .optional()- .describe(- 'How often to sync. The fastest sync frequency is 5 minutes.\n\n\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- sync_time_of_day: zod.iso.time({}).nullish().describe('UTC time of day to run the sync (HH:MM:SS).'),- primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),- cdc_table_mode: zod- .union([- zod- .enum(['consolidated', 'cdc_only', 'both'])- .describe('\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'),- zod.null(),- ])- .optional()- .describe(- 'For CDC syncs: consolidated, cdc_only, or both.\n\n\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'- ),- enabled_columns: zod- .array(zod.string())- .nullish()- .describe(- 'Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here.'- ),- row_filters: zod- .array(- zod.object({- column: zod.string(),- operator: zod.string().describe('One of: > >= < <= = != IN \"NOT IN\".'),- value: zod- .unknown()- .describe(- "Comparison value; must match the column's type. For `IN` \/ `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- ),- })- )- .nullish()- .describe(- "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`\/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`\/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- ),- api_version: zod- .string()- .max(externalDataSchemasReloadCreateBodyApiVersionMax)- .nullish()- .describe(- "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- ),- })- .describe('A schema of an external data source: its sync configuration and the warehouse table it syncs into.')-export const ExternalDataSchemasResyncCreateParams = /* @__PURE__ */ zod.object({id: zod.string().describe('A UUID string identifying this external data schema.'),project_id: zod@@ -388,107 +287,6 @@ export const ExternalDataSchemasResyncCreateParams = /* @__PURE__ */ zod.object(),})-export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin = 0-export const externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax = 5184000--export const externalDataSchemasResyncCreateBodyApiVersionMax = 128--export const ExternalDataSchemasResyncCreateBody = /* @__PURE__ */ zod- .object({- should_sync: zod.boolean().optional(),- sync_type: zod- .union([- zod- .enum(['full_refresh', 'incremental', 'append', 'webhook', 'cdc', 'xmin'])- .describe(- '\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- zod.null(),- ])- .optional()- .describe(- 'Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n\* `full_refresh` - full_refresh\n\* `incremental` - incremental\n\* `append` - append\n\* `webhook` - webhook\n\* `cdc` - cdc\n\* `xmin` - xmin'- ),- incremental_field: zod.string().nullish().describe('Column name used to track sync progress.'),- incremental_field_type: zod- .union([- zod- .enum(['integer', 'numeric', 'datetime', 'date', 'timestamp', 'objectid', 'xid'])- .describe(- '\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- zod.null(),- ])- .optional()- .describe(- 'Data type of the incremental field.\n\n\* `integer` - integer\n\* `numeric` - numeric\n\* `datetime` - datetime\n\* `date` - date\n\* `timestamp` - timestamp\n\* `objectid` - objectid\n\* `xid` - xid'- ),- incremental_field_lookback_seconds: zod- .number()- .min(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMin)- .max(externalDataSchemasResyncCreateBodyIncrementalFieldLookbackSecondsMax)- .nullish()- .describe(- 'Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp\/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days).'- ),- sync_frequency: zod- .union([- zod- .enum(['never', '5min', '15min', '30min', '1hour', '6hour', '12hour', '24hour', '7day', '30day'])- .describe(- '\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- zod.null(),- ])- .optional()- .describe(- 'How often to sync. The fastest sync frequency is 5 minutes.\n\n\* `never` - never\n\* `5min` - 5min\n\* `15min` - 15min\n\* `30min` - 30min\n\* `1hour` - 1hour\n\* `6hour` - 6hour\n\* `12hour` - 12hour\n\* `24hour` - 24hour\n\* `7day` - 7day\n\* `30day` - 30day'- ),- sync_time_of_day: zod.iso.time({}).nullish().describe('UTC time of day to run the sync (HH:MM:SS).'),- primary_key_columns: zod.array(zod.string()).nullish().describe('Column names for primary key deduplication.'),- cdc_table_mode: zod- .union([- zod- .enum(['consolidated', 'cdc_only', 'both'])- .describe('\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'),- zod.null(),- ])- .optional()- .describe(- 'For CDC syncs: consolidated, cdc_only, or both.\n\n\* `consolidated` - consolidated\n\* `cdc_only` - cdc_only\n\* `both` - both'- ),- enabled_columns: zod- .array(zod.string())- .nullish()- .describe(- 'Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here.'- ),- row_filters: zod- .array(- zod.object({- column: zod.string(),- operator: zod.string().describe('One of: > >= < <= = != IN \"NOT IN\".'),- value: zod- .unknown()- .describe(- "Comparison value; must match the column's type. For `IN` \/ `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- ),- })- )- .nullish()- .describe(- "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`\/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`\/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- ),- api_version: zod- .string()- .max(externalDataSchemasResyncCreateBodyApiVersionMax)- .nullish()- .describe(- "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- ),- })- .describe('A schema of an external data source: its sync configuration and the warehouse table it syncs into.')-/*** Create, Read, Update and Delete External data Sources.*/diff --git a/services/mcp/src/tools/generated/warehouse_sources.ts b/services/mcp/src/tools/generated/warehouse_sources.tsindex 58b28189d14d..3168aad6d883 100644--- a/services/mcp/src/tools/generated/warehouse_sources.ts+++ b/services/mcp/src/tools/generated/warehouse_sources.ts@@ -10,9 +10,7 @@ import {ExternalDataSchemasListQueryParams,ExternalDataSchemasPartialUpdateBody,ExternalDataSchemasPartialUpdateParams,- ExternalDataSchemasReloadCreateBody,ExternalDataSchemasReloadCreateParams,- ExternalDataSchemasResyncCreateBody,ExternalDataSchemasResyncCreateParams,ExternalDataSchemasRetrieveParams,ExternalDataSourcesConnectLinkRetrieveQueryParams,@@ -296,111 +294,31 @@ const externalDataSchemasPartialUpdate = (): ToolBase<},})-const ExternalDataSchemasReloadSchema = ExternalDataSchemasReloadCreateParams.omit({ project_id: true }).extend(- ExternalDataSchemasReloadCreateBody.shape-)+const ExternalDataSchemasReloadSchema = ExternalDataSchemasReloadCreateParams.omit({ project_id: true })const externalDataSchemasReload = (): ToolBase<typeof ExternalDataSchemasReloadSchema, unknown> => ({name: 'external-data-schemas-reload',schema: ExternalDataSchemasReloadSchema,handler: async (context: Context, params: z.infer<typeof ExternalDataSchemasReloadSchema>) => {const projectId = await context.stateManager.getProjectId()- const body: Record<string, unknown> = {}- if (params.should_sync !== undefined) {- body['should_sync'] = params.should_sync- }- if (params.sync_type !== undefined) {- body['sync_type'] = params.sync_type- }- if (params.incremental_field !== undefined) {- body['incremental_field'] = params.incremental_field- }- if (params.incremental_field_type !== undefined) {- body['incremental_field_type'] = params.incremental_field_type- }- if (params.incremental_field_lookback_seconds !== undefined) {- body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds- }- if (params.sync_frequency !== undefined) {- body['sync_frequency'] = params.sync_frequency- }- if (params.sync_time_of_day !== undefined) {- body['sync_time_of_day'] = params.sync_time_of_day- }- if (params.primary_key_columns !== undefined) {- body['primary_key_columns'] = params.primary_key_columns- }- if (params.cdc_table_mode !== undefined) {- body['cdc_table_mode'] = params.cdc_table_mode- }- if (params.enabled_columns !== undefined) {- body['enabled_columns'] = params.enabled_columns- }- if (params.row_filters !== undefined) {- body['row_filters'] = params.row_filters- }- if (params.api_version !== undefined) {- body['api_version'] = params.api_version- }const result = await context.api.request<unknown>({method: 'POST',path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_schemas/${encodeURIComponent(String(params.id))}/reload/`,- body,})return result},})-const ExternalDataSchemasResyncSchema = ExternalDataSchemasResyncCreateParams.omit({ project_id: true }).extend(- ExternalDataSchemasResyncCreateBody.shape-)+const ExternalDataSchemasResyncSchema = ExternalDataSchemasResyncCreateParams.omit({ project_id: true })const externalDataSchemasResync = (): ToolBase<typeof ExternalDataSchemasResyncSchema, unknown> => ({name: 'external-data-schemas-resync',schema: ExternalDataSchemasResyncSchema,handler: async (context: Context, params: z.infer<typeof ExternalDataSchemasResyncSchema>) => {const projectId = await context.stateManager.getProjectId()- const body: Record<string, unknown> = {}- if (params.should_sync !== undefined) {- body['should_sync'] = params.should_sync- }- if (params.sync_type !== undefined) {- body['sync_type'] = params.sync_type- }- if (params.incremental_field !== undefined) {- body['incremental_field'] = params.incremental_field- }- if (params.incremental_field_type !== undefined) {- body['incremental_field_type'] = params.incremental_field_type- }- if (params.incremental_field_lookback_seconds !== undefined) {- body['incremental_field_lookback_seconds'] = params.incremental_field_lookback_seconds- }- if (params.sync_frequency !== undefined) {- body['sync_frequency'] = params.sync_frequency- }- if (params.sync_time_of_day !== undefined) {- body['sync_time_of_day'] = params.sync_time_of_day- }- if (params.primary_key_columns !== undefined) {- body['primary_key_columns'] = params.primary_key_columns- }- if (params.cdc_table_mode !== undefined) {- body['cdc_table_mode'] = params.cdc_table_mode- }- if (params.enabled_columns !== undefined) {- body['enabled_columns'] = params.enabled_columns- }- if (params.row_filters !== undefined) {- body['row_filters'] = params.row_filters- }- if (params.api_version !== undefined) {- body['api_version'] = params.api_version- }const result = await context.api.request<unknown>({method: 'POST',path: `/api/projects/${encodeURIComponent(String(projectId))}/external_data_schemas/${encodeURIComponent(String(params.id))}/resync/`,- body,})return result},diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.jsonindex 3614025849dd..567fb6f27984 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-reload.json@@ -1,167 +1,9 @@{"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {- "api_version": {- "anyOf": [- {- "maxLength": 128,- "type": "string"- },- {- "type": "null"- }- ],- "description": "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- },- "cdc_table_mode": {- "anyOf": [- {- "description": "* `consolidated` - consolidated\n* `cdc_only` - cdc_only\n* `both` - both",- "enum": ["consolidated", "cdc_only", "both"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "For CDC syncs: consolidated, cdc_only, or both.\n\n* `consolidated` - consolidated\n* `cdc_only` - cdc_only\n* `both` - both"- },- "enabled_columns": {- "anyOf": [- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here."- },"id": {"description": "A UUID string identifying this external data schema.","type": "string"- },- "incremental_field": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "description": "Column name used to track sync progress."- },- "incremental_field_lookback_seconds": {- "anyOf": [- {- "maximum": 5184000,- "minimum": 0,- "type": "number"- },- {- "type": "null"- }- ],- "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."- },- "incremental_field_type": {- "anyOf": [- {- "description": "* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid",- "enum": ["integer", "numeric", "datetime", "date", "timestamp", "objectid", "xid"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid"- },- "primary_key_columns": {- "anyOf": [- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Column names for primary key deduplication."- },- "row_filters": {- "anyOf": [- {- "items": {- "properties": {- "column": {- "type": "string"- },- "operator": {- "description": "One of: > >= < <= = != IN \"NOT IN\".",- "type": "string"- },- "value": {- "description": "Comparison value; must match the column's type. For `IN` / `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- }- },- "required": ["column", "operator", "value"],- "type": "object"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- },- "should_sync": {- "type": "boolean"- },- "sync_frequency": {- "anyOf": [- {- "description": "* `never` - never\n* `5min` - 5min\n* `15min` - 15min\n* `30min` - 30min\n* `1hour` - 1hour\n* `6hour` - 6hour\n* `12hour` - 12hour\n* `24hour` - 24hour\n* `7day` - 7day\n* `30day` - 30day",- "enum": ["never", "5min", "15min", "30min", "1hour", "6hour", "12hour", "24hour", "7day", "30day"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "How often to sync. The fastest sync frequency is 5 minutes.\n\n* `never` - never\n* `5min` - 5min\n* `15min` - 15min\n* `30min` - 30min\n* `1hour` - 1hour\n* `6hour` - 6hour\n* `12hour` - 12hour\n* `24hour` - 24hour\n* `7day` - 7day\n* `30day` - 30day"- },- "sync_time_of_day": {- "anyOf": [- {- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",- "type": "string"- },- {- "type": "null"- }- ],- "description": "UTC time of day to run the sync (HH:MM:SS)."- },- "sync_type": {- "anyOf": [- {- "description": "* `full_refresh` - full_refresh\n* `incremental` - incremental\n* `append` - append\n* `webhook` - webhook\n* `cdc` - cdc\n* `xmin` - xmin",- "enum": ["full_refresh", "incremental", "append", "webhook", "cdc", "xmin"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n* `full_refresh` - full_refresh\n* `incremental` - incremental\n* `append` - append\n* `webhook` - webhook\n* `cdc` - cdc\n* `xmin` - xmin"}},"required": ["id"],diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.jsonindex 3614025849dd..567fb6f27984 100644--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/external-data-schemas-resync.json@@ -1,167 +1,9 @@{"$schema": "https://json-schema.org/draft/2020-12/schema","properties": {- "api_version": {- "anyOf": [- {- "maxLength": 128,- "type": "string"- },- {- "type": "null"- }- ],- "description": "Vendor API version override for this schema. `null` (default) syncs on the source's pinned version. Must be one of the source type's supported versions. User-managed: version-migration tooling never changes it. Not available for webhook-sync schemas."- },- "cdc_table_mode": {- "anyOf": [- {- "description": "* `consolidated` - consolidated\n* `cdc_only` - cdc_only\n* `both` - both",- "enum": ["consolidated", "cdc_only", "both"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "For CDC syncs: consolidated, cdc_only, or both.\n\n* `consolidated` - consolidated\n* `cdc_only` - cdc_only\n* `both` - both"- },- "enabled_columns": {- "anyOf": [- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Names of source columns to sync. `null` (default) syncs all columns. Primary-key columns and the active incremental field are always retained, even if not listed here."- },"id": {"description": "A UUID string identifying this external data schema.","type": "string"- },- "incremental_field": {- "anyOf": [- {- "type": "string"- },- {- "type": "null"- }- ],- "description": "Column name used to track sync progress."- },- "incremental_field_lookback_seconds": {- "anyOf": [- {- "maximum": 5184000,- "minimum": 0,- "type": "number"- },- {- "type": "null"- }- ],- "description": "Seconds to subtract from the stored incremental watermark at sync time, so each incremental run re-reads a rolling overlap window and catches late or backdated rows. Applies to timestamp/date incremental fields only. The stored watermark is unchanged. Maximum 5184000 (60 days)."- },- "incremental_field_type": {- "anyOf": [- {- "description": "* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid",- "enum": ["integer", "numeric", "datetime", "date", "timestamp", "objectid", "xid"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "Data type of the incremental field.\n\n* `integer` - integer\n* `numeric` - numeric\n* `datetime` - datetime\n* `date` - date\n* `timestamp` - timestamp\n* `objectid` - objectid\n* `xid` - xid"- },- "primary_key_columns": {- "anyOf": [- {- "items": {- "type": "string"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Column names for primary key deduplication."- },- "row_filters": {- "anyOf": [- {- "items": {- "properties": {- "column": {- "type": "string"- },- "operator": {- "description": "One of: > >= < <= = != IN \"NOT IN\".",- "type": "string"- },- "value": {- "description": "Comparison value; must match the column's type. For `IN` / `NOT IN`, a comma-separated list (e.g. `1, 2, 3` or `'a','b'`)."- }- },- "required": ["column", "operator", "value"],- "type": "object"- },- "type": "array"- },- {- "type": "null"- }- ],- "description": "Predicates ANDed onto the source query so only matching rows sync. Each is `{column, operator, value}`; `null`/empty (default) syncs all rows. The operator must be one of `> >= < <= = != IN \"NOT IN\"` and the value must match the column's type (for `IN`/`NOT IN`, a comma-separated list like `1, 2, 3` or `'a','b'`). Applied on the next sync — not retroactive to already-synced rows."- },- "should_sync": {- "type": "boolean"- },- "sync_frequency": {- "anyOf": [- {- "description": "* `never` - never\n* `5min` - 5min\n* `15min` - 15min\n* `30min` - 30min\n* `1hour` - 1hour\n* `6hour` - 6hour\n* `12hour` - 12hour\n* `24hour` - 24hour\n* `7day` - 7day\n* `30day` - 30day",- "enum": ["never", "5min", "15min", "30min", "1hour", "6hour", "12hour", "24hour", "7day", "30day"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "How often to sync. The fastest sync frequency is 5 minutes.\n\n* `never` - never\n* `5min` - 5min\n* `15min` - 15min\n* `30min` - 30min\n* `1hour` - 1hour\n* `6hour` - 6hour\n* `12hour` - 12hour\n* `24hour` - 24hour\n* `7day` - 7day\n* `30day` - 30day"- },- "sync_time_of_day": {- "anyOf": [- {- "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?$",- "type": "string"- },- {- "type": "null"- }- ],- "description": "UTC time of day to run the sync (HH:MM:SS)."- },- "sync_type": {- "anyOf": [- {- "description": "* `full_refresh` - full_refresh\n* `incremental` - incremental\n* `append` - append\n* `webhook` - webhook\n* `cdc` - cdc\n* `xmin` - xmin",- "enum": ["full_refresh", "incremental", "append", "webhook", "cdc", "xmin"],- "type": "string"- },- {- "type": "null"- }- ],- "description": "Sync strategy: incremental, full_refresh, append, cdc, or xmin.\n\n* `full_refresh` - full_refresh\n* `incremental` - incremental\n* `append` - append\n* `webhook` - webhook\n* `cdc` - cdc\n* `xmin` - xmin"}},"required": ["id"],