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.

feat(data-warehouse): add hatchet workflows, workers, task events and timings tables (#110783)

Tom Owers412f579cdd77
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
index 33647d9a276f..231ffb33a0ad 100644
--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
@@ -649,7 +649,6 @@
1 products/warehouse_sources/backend/temporal/data_imports/sources/harvey/harvey.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/harvey/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/hatchet.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/healthchecks/healthchecks.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/healthchecks/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/height/settings.py
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
index d494fb16f6ba..66992805b5de 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md
@@ -3912,18 +3912,19 @@ Note: Harvey publishes six OpenAPI specs (listed in https://developers.harvey.ai
## Hatchet — gaps
-Today (4): `event_keys`, `events`, `tasks`, `workflow_runs`
+Today (8): `event_keys`, `events`, `task_events`, `task_timings`, `tasks`, `workers`, `workflow_runs`, `workflows`
Diffed against: <https://raw.githubusercontent.com/hatchet-dev/hatchet/main/api-contracts/openapi/openapi.yaml>
-- [ ] `workflows (GET /api/v1/tenants/{tenant}/workflows, GET /api/v1/workflows/{workflow}/versions)` — lookup resolving the workflow ID and version carried on every synced workflow run and task (high)
-- [ ] `task events (GET /api/v1/stable/tasks/{task}/task-events, GET /api/v1/stable/workflow-runs/{id}/task-events)` — state-transition history (queued, started, retried, failed) behind each task's final status (high)
-- [ ] `workers (GET /api/v1/tenants/{tenant}/worker, GET /api/v1/workers/{worker})` — lookup identifying which worker executed a synced task, plus worker availability (high)
+- [x] `workflows (GET /api/v1/tenants/{tenant}/workflows)` — lookup resolving the workflow ID carried on every synced workflow run and task (high)
+- [ ] `workflow versions (GET /api/v1/workflows/{workflow}/versions)` — returns one version per call (latest, or one by id), so there is no listable version history to sync (high)
+- [x] `task events (GET /api/v1/stable/tasks/{task}/task-events, GET /api/v1/stable/workflow-runs/{id}/task-events)` — state-transition history (queued, started, retried, failed) behind each task's final status (high)
+- [x] `workers (GET /api/v1/tenants/{tenant}/worker, GET /api/v1/workers/{worker})` — lookup identifying which worker executed a synced task, plus worker availability (high)
- [ ] `task metrics (GET /api/v1/stable/tenants/{tenant}/task-metrics, /task-point-metrics, /task-stats)` — the vendor's headline throughput and status-count series for queue health dashboards (medium)
- [ ] `queue metrics (GET /api/v1/tenants/{tenant}/queue-metrics, /step-run-queue-metrics)` — backlog depth per queue - the standard capacity-planning metric (medium)
- [ ] `scheduled runs (GET /api/v1/tenants/{tenant}/workflows/scheduled)` — upcoming and past scheduled triggers, joinable to workflow_runs (medium)
- [ ] `crons (GET /api/v1/tenants/{tenant}/workflows/crons)` — cron definitions that explain the trigger source of recurring runs (medium)
-- [ ] `task timings (GET /api/v1/stable/workflow-runs/{id}/task-timings)` — per-task duration breakdown within a run - latency attribution (medium)
+- [x] `task timings (GET /api/v1/stable/workflow-runs/{id}/task-timings)` — per-task duration breakdown within a run - latency attribution (medium)
- [ ] `tenant members (GET /api/v1/tenants/{tenant}/members)` — membership table for the tenant whose runs are synced (medium)
- [ ] `logs (GET /api/v1/stable/tenants/{tenant}/logs, /tasks/{task}/logs)` — task log lines for failure triage alongside run rows (medium)
- [ ] `workflow run metrics (GET /api/v1/tenants/{tenant}/workflows/runs/metrics, GET /api/v1/workflows/{workflow}/metrics)` — success/failure counts per workflow without re-aggregating raw runs (low)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/canonical_descriptions.py
index 6bb2524649e7..a1c1eb5c6a0a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/canonical_descriptions.py
@@ -81,4 +81,87 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"key": "An event key seen in the tenant.",
},
},
+ "workflows": {
+ "description": "A workflow defined in the Hatchet tenant. Workflow runs and tasks reference it by id.",
+ "docs_url": "https://docs.hatchet.run/home/your-first-task",
+ "columns": {
+ "id": "Unique identifier for the workflow.",
+ "created_at": "Time at which the workflow was created.",
+ "updated_at": "Time at which the workflow was last updated.",
+ "name": "The name of the workflow.",
+ "description": "The description of the workflow.",
+ "isPaused": "Whether the workflow is paused.",
+ "pausedWorkflowCronRunQueueBehavior": "What happens to cron runs that fire while the workflow is paused.",
+ "pausedWorkflowScheduledRunQueueBehavior": "What happens to scheduled runs that fire while the workflow is paused.",
+ },
+ },
+ "workers": {
+ "description": "A worker registered with the Hatchet tenant. Only workers that sent a heartbeat in the last 24 hours are listed.",
+ "docs_url": "https://docs.hatchet.run/home/workers",
+ "columns": {
+ "id": "Unique identifier for the worker.",
+ "created_at": "Time at which the worker was registered.",
+ "updated_at": "Time at which the worker was last updated.",
+ "name": "The name of the worker.",
+ "type": "The worker type (SELFHOSTED, MANAGED, or WEBHOOK).",
+ "status": "The worker status (ACTIVE, INACTIVE, or PAUSED).",
+ "lastHeartbeatAt": "Time at which the worker last sent a heartbeat.",
+ "lastListenerEstablished": "Time at which the worker last established a listener.",
+ "actions": "The actions the worker can execute.",
+ "registeredWorkflows": "The workflows registered on the worker.",
+ "slots": "The semaphore slots for the worker.",
+ "recentStepRuns": "The recent step runs for the worker.",
+ "slotConfig": "Slot availability and limits per slot type.",
+ "dispatcherId": "Identifier of the dispatcher the worker is connected to.",
+ "labels": "The labels set on the worker.",
+ "webhookUrl": "The webhook URL for a webhook worker.",
+ "webhookId": "Identifier of the webhook for a webhook worker.",
+ "runtimeInfo": "Information about the SDK, language, and runtime of the worker.",
+ },
+ },
+ "task_events": {
+ "description": "A state transition of a Hatchet task (for example assigned, started, retried, failed), with one row per event in each workflow run.",
+ "docs_url": "https://docs.hatchet.run/home/runs-and-tasks",
+ "columns": {
+ "id": "Identifier of the task event.",
+ "taskId": "External identifier of the task the event belongs to.",
+ "timestamp": "Time at which the event occurred.",
+ "eventType": "The type of the event, such as CREATED, ASSIGNED, STARTED, FINISHED, FAILED, or RETRYING.",
+ "message": "Message attached to the event.",
+ "errorMessage": "Error message attached to the event, if any.",
+ "output": "Output payload attached to the event, if any.",
+ "workerId": "Identifier of the worker associated with the event.",
+ "taskDisplayName": "Display name of the task.",
+ "retryCount": "Number of times the task had been retried when the event occurred.",
+ "attempt": "The attempt number of the task when the event occurred.",
+ "workflow_run_id": "External identifier of the workflow run the task belongs to.",
+ "workflow_run_created_at": "Time at which the parent workflow run was created.",
+ },
+ },
+ "task_timings": {
+ "description": "Queued, started, and finished times of each task in a Hatchet workflow run, for latency attribution.",
+ "docs_url": "https://docs.hatchet.run/home/runs-and-tasks",
+ "columns": {
+ "id": "Identifier of the task timing resource.",
+ "created_at": "Time at which the task timing resource was created.",
+ "updated_at": "Time at which the task timing resource was last updated.",
+ "depth": "Depth of the task in the run's task tree.",
+ "status": "The task status (QUEUED, RUNNING, COMPLETED, CANCELLED, or FAILED).",
+ "isEvicted": "Whether the task was evicted from its worker.",
+ "taskDisplayName": "Display name of the task.",
+ "taskExternalId": "External identifier of the task.",
+ "taskId": "Internal numeric identifier of the task.",
+ "taskInsertedAt": "Time at which the task was inserted.",
+ "tenantId": "Identifier of the tenant that owns the task.",
+ "parentTaskExternalId": "External identifier of the parent task, if any.",
+ "queuedAt": "Time at which the task was queued.",
+ "startedAt": "Time at which the task started.",
+ "finishedAt": "Time at which the task finished.",
+ "workflowRunId": "Identifier of the workflow run the task belongs to.",
+ "retryCount": "Number of times the task has been retried.",
+ "attempt": "The current attempt number.",
+ "workflow_run_id": "External identifier of the workflow run the timings were fetched for.",
+ "workflow_run_created_at": "Time at which the parent workflow run was created.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/hatchet.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/hatchet.py
index 1c53487108af..85e240a14a61 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/hatchet.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/hatchet.py
@@ -5,13 +5,14 @@ import dataclasses
from collections.abc import Iterator
from datetime import UTC, date, datetime, timedelta
from typing import Any, Optional
-from urllib.parse import urlencode, urlparse
+from urllib.parse import quote, urlencode, urlparse
import requests
from structlog.types import FilteringBoundLogger
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
from posthog.cloud_utils import is_cloud
+from posthog.dataclasses import frozen
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.batcher import Batcher
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
@@ -58,6 +59,13 @@ class HatchetResumeConfig:
since: str | None = None
+@frozen
+class HatchetPage:
+ offset: int
+ rows: list[Any]
+ is_last_page: bool
+
+
@dataclasses.dataclass(frozen=True)
class HatchetConnection:
base_url: str
@@ -224,7 +232,13 @@ def _build_url(base_url: str, path: str, params: dict[str, Any]) -> str:
wait=wait_exponential_jitter(initial=1, max=30),
reraise=True,
)
-def _fetch_page(session: requests.Session, url: str, headers: dict[str, str], logger: FilteringBoundLogger) -> Any:
+def _fetch_page(
+ session: requests.Session,
+ url: str,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+ allow_not_found: bool = False,
+) -> Any:
response = session.get(url, headers=headers, timeout=60)
# 429 and transient 5xx are retryable; auth/permission errors below are not.
@@ -238,6 +252,9 @@ def _fetch_page(session: requests.Session, url: str, headers: dict[str, str], lo
f"Hatchet API returned an unexpected redirect: status={response.status_code}, url={url}"
)
+ if allow_not_found and response.status_code == 404:
+ return None
+
if not response.ok:
logger.error(f"Hatchet API error: status={response.status_code}, body={response.text}, url={url}")
response.raise_for_status()
@@ -354,6 +371,46 @@ def get_rows(
# The window actually in use (after any resume override); re-saved state pins this same window.
effective_since = params.get("since")
+ for page in _iter_pages(session, connection, path, params, offset, config, headers, logger):
+ rows = (
+ _iter_fan_out_rows(session, connection, page.rows, config.fan_out_path, config, headers, logger)
+ if config.fan_out_path
+ else (_normalize_row(item) for item in page.rows)
+ )
+ for row in rows:
+ batcher.batch(row)
+ if batcher.should_yield():
+ yield batcher.get_table()
+ # Save state AFTER yielding so a crash re-reads this page rather than skipping it.
+ if not page.is_last_page:
+ resumable_source_manager.save_state(HatchetResumeConfig(offset=page.offset, since=effective_since))
+
+ if batcher.should_yield(include_incomplete_chunk=True):
+ yield batcher.get_table()
+
+
+def _extract_rows(data: Any, config: HatchetEndpointConfig) -> list[Any]:
+ # List endpoints wrap results as `{"rows": [...]}`, but some (e.g. event keys) return a bare
+ # top-level array; take that directly so those endpoints don't silently sync zero rows.
+ if isinstance(data, list):
+ return data
+ if isinstance(data, dict):
+ rows = data.get(config.response_data_path) or []
+ return rows if isinstance(rows, list) else []
+ return []
+
+
+def _iter_pages(
+ session: requests.Session,
+ connection: HatchetConnection,
+ path: str,
+ params: dict[str, Any],
+ offset: int,
+ config: HatchetEndpointConfig,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+) -> Iterator[HatchetPage]:
+ """Yield each non-empty page of an offset-paginated list."""
while True:
# Checkpoint the offset of the page we're about to read. The batcher accumulates across
# pages and only flushes at its size threshold, so on resume we re-read from this page and
@@ -363,16 +420,9 @@ def get_rows(
url = _build_url(connection.base_url, path, page_params)
data = _fetch_page(session, url, headers, logger)
- # List endpoints wrap results as `{"rows": [...]}`, but some (e.g. event keys) return a bare
- # top-level array; take that directly so those endpoints don't silently sync zero rows.
- if isinstance(data, list):
- rows = data
- elif isinstance(data, dict):
- rows = data.get(config.response_data_path, [])
- else:
- rows = []
- if not isinstance(rows, list) or not rows:
- break
+ rows = _extract_rows(data, config)
+ if not rows:
+ return
# A short page is the last page; a full page can still be the last if pagination says so.
is_last_page = len(rows) < config.page_size
@@ -383,20 +433,42 @@ def get_rows(
if isinstance(current_page, int) and isinstance(num_pages, int) and current_page >= num_pages:
is_last_page = True
- for item in rows:
- batcher.batch(_normalize_row(item))
- if batcher.should_yield():
- yield batcher.get_table()
- # Save state AFTER yielding so a crash re-reads this page rather than skipping it.
- if not is_last_page:
- resumable_source_manager.save_state(HatchetResumeConfig(offset=page_offset, since=effective_since))
+ yield HatchetPage(offset=page_offset, rows=rows, is_last_page=is_last_page)
if is_last_page:
- break
+ return
offset = page_offset + config.page_size
- if batcher.should_yield(include_incomplete_chunk=True):
- yield batcher.get_table()
+
+def _iter_fan_out_rows(
+ session: requests.Session,
+ connection: HatchetConnection,
+ parent_runs: list[Any],
+ fan_out_path: str,
+ config: HatchetEndpointConfig,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+) -> Iterator[dict[str, Any]]:
+ """Fetch the per-run child rows for one page of parent workflow runs."""
+ for parent in parent_runs:
+ run = _normalize_row(parent)
+ run_id = run.get("id")
+ if not run_id:
+ continue
+
+ child_path = fan_out_path.format(workflow_run=quote(str(run_id), safe=""))
+ data = _fetch_page(
+ session, _build_url(connection.base_url, child_path, {}), headers, logger, allow_not_found=True
+ )
+ # The run was listed but has since aged out of retention; skip it rather than fail the sync.
+ if data is None:
+ continue
+
+ for item in _extract_rows(data, config):
+ row = _normalize_row(item)
+ row["workflow_run_id"] = run_id
+ row["workflow_run_created_at"] = run.get("created_at")
+ yield row
def hatchet_source(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/settings.py
index 853067b2b87a..50d2d68d6588 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/settings.py
@@ -5,7 +5,7 @@ from typing import Literal, Optional
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
-@dataclass
+@dataclass(frozen=True)
class HatchetEndpointConfig:
name: str
# Tenant-scoped path template. `{tenant}` is filled with the tenant UUID derived from the token.
@@ -37,6 +37,10 @@ class HatchetEndpointConfig:
# watermark only at successful job end (a partial run's max says nothing about the older rows
# it never reached), and resume replays from the saved offset instead.
sort_mode: Literal["asc", "desc"] = "asc"
+ # Per-workflow-run child path (`{workflow_run}` is the run's external id). When set, `path` and the
+ # time-window settings describe the parent workflow-runs listing we fan out over, and each child
+ # row carries `workflow_run_id` / `workflow_run_created_at` from its parent run.
+ fan_out_path: Optional[str] = None
# `since` is required on the workflow-runs/tasks endpoint even for a full refresh. Retention windows
@@ -52,6 +56,21 @@ _TIME_WINDOW_INCREMENTAL_FIELDS: list[IncrementalField] = [
},
]
+# Fan-out children have no server-side time filter of their own; the parent run's creation time is
+# the cursor, since that is what the parent listing's `since` window filters on.
+_FAN_OUT_INCREMENTAL_FIELDS: list[IncrementalField] = [
+ {
+ "label": "workflow_run_created_at",
+ "type": IncrementalFieldType.DateTime,
+ "field": "workflow_run_created_at",
+ "field_type": IncrementalFieldType.DateTime,
+ },
+]
+
+# Parent listing for the per-run fan-out tables: DAG runs plus standalone tasks (child runs are
+# listed too), without payloads since only the run id and creation time are read.
+_FAN_OUT_PARENT_PARAMS = {"only_tasks": "false", "include_payloads": "false"}
+
HATCHET_ENDPOINTS: dict[str, HatchetEndpointConfig] = {
# Top-level workflow (DAG) runs plus standalone task runs. `only_tasks=false` keeps the
@@ -107,6 +126,55 @@ HATCHET_ENDPOINTS: dict[str, HatchetEndpointConfig] = {
incremental_fields=[],
primary_keys=["key"],
),
+ # Workflow definitions in the tenant. No time filter, so full refresh only.
+ "workflows": HatchetEndpointConfig(
+ name="workflows",
+ path="/api/v1/tenants/{tenant}/workflows",
+ partition_key="created_at",
+ incremental_fields=[],
+ ),
+ # Workers registered with the tenant. The API only returns workers that sent a heartbeat in the
+ # last 24 hours, and status fields change constantly, so full refresh only.
+ "workers": HatchetEndpointConfig(
+ name="workers",
+ path="/api/v1/tenants/{tenant}/worker",
+ partition_key="created_at",
+ incremental_fields=[],
+ ),
+ # State-transition history of every task in a run. The API returns all of a run's events in one
+ # response (no pagination), so this fans out once per workflow run.
+ "task_events": HatchetEndpointConfig(
+ name="task_events",
+ path="/api/v1/stable/tenants/{tenant}/workflow-runs",
+ fan_out_path="/api/v1/stable/workflow-runs/{workflow_run}/task-events",
+ partition_key="workflow_run_created_at",
+ incremental_fields=_FAN_OUT_INCREMENTAL_FIELDS,
+ default_incremental_field="workflow_run_created_at",
+ supports_time_window=True,
+ requires_since=True,
+ default_lookback_days=30,
+ incremental_lookback=timedelta(days=1),
+ sort_mode="desc",
+ # Event ids are only documented as unique per task.
+ primary_keys=["taskId", "id"],
+ extra_params=_FAN_OUT_PARENT_PARAMS,
+ ),
+ # Queued/started/finished timings of the tasks in a run. Single unpaginated response per run.
+ "task_timings": HatchetEndpointConfig(
+ name="task_timings",
+ path="/api/v1/stable/tenants/{tenant}/workflow-runs",
+ fan_out_path="/api/v1/stable/workflow-runs/{workflow_run}/task-timings",
+ partition_key="workflow_run_created_at",
+ incremental_fields=_FAN_OUT_INCREMENTAL_FIELDS,
+ default_incremental_field="workflow_run_created_at",
+ supports_time_window=True,
+ requires_since=True,
+ default_lookback_days=30,
+ incremental_lookback=timedelta(days=1),
+ sort_mode="desc",
+ primary_keys=["workflow_run_id", "taskExternalId"],
+ extra_params=_FAN_OUT_PARENT_PARAMS,
+ ),
}
ENDPOINTS = tuple(HATCHET_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet.py
index 274aa89b99e3..f2c812a4c014 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet.py
@@ -6,6 +6,7 @@ from typing import Any
import pytest
from unittest import mock
+import requests
import structlog
from products.warehouse_sources.backend.temporal.data_imports.sources.hatchet.hatchet import (
@@ -14,6 +15,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.hatchet.ha
HatchetResumeConfig,
HatchetTokenError,
_build_initial_params,
+ _fetch_page,
_normalize_row,
_resolve_since,
get_rows,
@@ -337,6 +339,71 @@ class TestGetRows:
assert session.call_args.kwargs["redact_values"] == ("tok",)
assert session.call_args.kwargs["capture"] is False
+ def test_fan_out_tags_child_rows_with_parent_run_and_skips_purged_runs(self):
+ manager = FakeManager()
+ parent_page = {
+ "rows": [
+ {"metadata": {"id": "run-1", "createdAt": "2026-06-01T00:00:00Z", "updatedAt": "2026-06-01T00:00:00Z"}},
+ {
+ "metadata": {
+ "id": "run-gone",
+ "createdAt": "2026-06-02T00:00:00Z",
+ "updatedAt": "2026-06-02T00:00:00Z",
+ }
+ },
+ ],
+ "pagination": {"current_page": 1, "num_pages": 1},
+ }
+ child_pages = {
+ "/api/v1/stable/workflow-runs/run-1/task-events": {
+ "rows": [
+ {"id": 1, "taskId": "task-a", "eventType": "STARTED", "timestamp": "2026-06-01T00:00:01Z"},
+ {"id": 2, "taskId": "task-a", "eventType": "FINISHED", "timestamp": "2026-06-01T00:00:02Z"},
+ ],
+ "pagination": {},
+ },
+ "/api/v1/stable/workflow-runs/run-gone/task-events": None,
+ }
+ captured_urls: list[str] = []
+
+ def fake_fetch(session, url, headers, log, allow_not_found=False):
+ captured_urls.append(url)
+ path = url.removeprefix("https://cloud.example").split("?")[0]
+ if path in child_pages:
+ assert allow_not_found is True
+ return child_pages[path]
+ return parent_page
+
+ with mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.hatchet.hatchet._fetch_page",
+ side_effect=fake_fetch,
+ ):
+ rows = _collect(
+ get_rows("tok", self._connection(), "task_events", logger, manager, 1, True, None) # type: ignore[arg-type]
+ )
+
+ assert "/api/v1/stable/tenants/tenant-1/workflow-runs?" in captured_urls[0]
+ assert "include_payloads=false" in captured_urls[0]
+ assert [(r["id"], r["workflow_run_id"], r["workflow_run_created_at"]) for r in rows] == [
+ (1, "run-1", "2026-06-01T00:00:00Z"),
+ (2, "run-1", "2026-06-01T00:00:00Z"),
+ ]
+
+
+class TestFetchPage:
+ @pytest.mark.parametrize("allow_not_found", [True, False])
+ def test_not_found_is_skipped_only_when_allowed(self, allow_not_found):
+ response = requests.Response()
+ response.status_code = 404
+ session = mock.MagicMock()
+ session.get.return_value = response
+
+ if allow_not_found:
+ assert _fetch_page(session, "https://cloud.example/x", {}, logger, allow_not_found=True) is None
+ else:
+ with pytest.raises(requests.HTTPError):
+ _fetch_page(session, "https://cloud.example/x", {}, logger)
+
class TestValidateCredentials:
@pytest.mark.parametrize(
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet_source.py
index 9bda8dbafa4e..48c697f982ed 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hatchet/tests/test_hatchet_source.py
@@ -114,7 +114,16 @@ class TestHatchetSource:
tables = {t["name"]: t for t in self.source.get_documented_tables()}
- assert set(tables) == {"workflow_runs", "tasks", "events", "event_keys"}
+ assert set(tables) == {
+ "workflow_runs",
+ "tasks",
+ "events",
+ "event_keys",
+ "workflows",
+ "workers",
+ "task_events",
+ "task_timings",
+ }
assert tables["workflow_runs"]["description"]
assert "Incremental" in tables["workflow_runs"]["sync_methods"]
assert tables["event_keys"]["sync_methods"] == ["Full refresh"]