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 3 missing tables to the Hatchet source (#118378)

Tom Owers008eff21f8ab
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 c31c278c3aaf..bd6ff0384088 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
@@ -5707,7 +5707,7 @@ Note: Harvey publishes six OpenAPI specs (listed in https://developers.harvey.ai
## Hatchet — gaps
-Today (9): `event_keys`, `events`, `scheduled_runs`, `task_events`, `task_timings`, `tasks`, `workers`, `workflow_runs`, `workflows`
+Today (12): `crons`, `event_keys`, `events`, `logs`, `scheduled_runs`, `task_events`, `task_timings`, `tasks`, `tenant_members`, `workers`, `workflow_runs`, `workflows`
Diffed against: <https://raw.githubusercontent.com/hatchet-dev/hatchet/main/api-contracts/openapi/openapi.yaml>
@@ -5718,11 +5718,11 @@ Diffed against: <https://raw.githubusercontent.com/hatchet-dev/hatchet/main/api-
- [ ] `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). Skipped: `task-metrics` returns status counts for whatever window is requested and `task-point-metrics` changes bucket width with the requested range, so neither has a stable row grain (both are derivable from `tasks`). `task-stats` is a live queued/running gauge for autoscalers, with no history.
- [ ] `queue metrics (GET /api/v1/tenants/{tenant}/queue-metrics, /step-run-queue-metrics)` — backlog depth per queue - the standard capacity-planning metric (medium). Skipped: `queue-metrics` is deprecated and returns 400 on current Hatchet, and `step-run-queue-metrics` is a point-in-time gauge with no history to sync.
- [x] `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)
+- [x] `crons (GET /api/v1/tenants/{tenant}/workflows/crons)` — cron definitions that explain the trigger source of recurring runs (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)
+- [x] `tenant members (GET /api/v1/tenants/{tenant}/members)` — membership table for the tenant whose runs are synced (medium)
+- [x] `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). Skipped: the tenant endpoint returns one status-count object for whatever `createdAfter`/`createdBefore` window is requested, so it has no stable row grain (the counts derive from `workflow_runs`). The per-workflow endpoint returns concurrency group-key counts, not success/failure counts.
- [ ] `rate limits (GET /api/v1/tenants/{tenant}/rate-limits)` — current vs limit consumption per key - explains queued-but-not-running tasks (low)
Note: The connector targets the stable v1 API (/api/v1/stable/tenants/{tenant}/...), but several still-current resources (workflows, workers, crons, scheduled, members, queue-metrics) live only under the older /api/v1/tenants/{tenant}/... prefix in the same spec. Webhooks, API tokens, feature flags, SNS/Slack integrations and alerting email groups were excluded as configuration.
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 b178cf42e16c..dd9e1ec94dca 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
@@ -160,6 +160,55 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"priority": "Priority of the triggered run, from 1 to 3.",
},
},
+ "crons": {
+ "description": "A cron trigger that runs a Hatchet workflow on a recurring schedule.",
+ "docs_url": "https://docs.hatchet.run/home/cron-runs",
+ "columns": {
+ "id": "Unique identifier for the cron trigger.",
+ "created_at": "Time at which the cron trigger was created.",
+ "updated_at": "Time at which the cron trigger was last updated.",
+ "tenantId": "Identifier of the tenant that owns the cron trigger.",
+ "workflowId": "Identifier of the workflow to trigger.",
+ "workflowName": "Name of the workflow to trigger.",
+ "workflowVersionId": "Identifier of the workflow version to trigger.",
+ "cron": "The cron expression that sets when the workflow runs.",
+ "name": "The name of the cron trigger.",
+ "input": "The input payload the workflow is triggered with.",
+ "additionalMetadata": "Arbitrary key-value metadata attached to the runs the cron triggers.",
+ "enabled": "Whether the cron trigger is enabled.",
+ "method": "How the cron trigger was created: DEFAULT (declared in code) or API.",
+ "priority": "Priority of the triggered runs, from 1 to 3.",
+ },
+ },
+ "tenant_members": {
+ "description": "A user with access to the Hatchet tenant, with the user's role.",
+ "docs_url": "https://docs.hatchet.run/home",
+ "columns": {
+ "id": "Unique identifier for the tenant membership.",
+ "created_at": "Time at which the membership was created.",
+ "updated_at": "Time at which the membership was last updated.",
+ "user": "The email address and display name of the user.",
+ "role": "The role of the user in the tenant (OWNER, ADMIN, MEMBER, or VIEWER).",
+ "canViewPayloads": "Whether the member can view task, event, and log payloads.",
+ "tenant": "The tenant the membership belongs to.",
+ "manually_added": "Whether the membership was granted explicitly, not synced from user-group tags.",
+ },
+ },
+ "logs": {
+ "description": "A log line emitted by a Hatchet task.",
+ "docs_url": "https://docs.hatchet.run/home/logging",
+ "columns": {
+ "id": "Identifier computed from the log line's fields. The API returns no log line id.",
+ "createdAt": "Time at which the log line was created.",
+ "message": "The log message. Empty when the API token cannot view payloads.",
+ "metadata": "Structured metadata attached to the log line.",
+ "level": "The log level (DEBUG, INFO, WARN, or ERROR).",
+ "taskExternalId": "External identifier of the task that emitted the log line.",
+ "taskDisplayName": "Display name of the task that emitted the log line.",
+ "retryCount": "Number of times the task had been retried when the line was logged.",
+ "attempt": "The attempt number of the task when the line was logged.",
+ },
+ },
"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",
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 85e240a14a61..5f6177576702 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
@@ -1,6 +1,7 @@
import re
import json
import base64
+import hashlib
import dataclasses
from collections.abc import Iterator
from datetime import UTC, date, datetime, timedelta
@@ -35,6 +36,9 @@ HOST_NOT_ALLOWED_ERROR = "Hatchet host is not allowed"
# Returned when a cloud connection would send the bearer token over plaintext HTTP.
INSECURE_SCHEME_ERROR = "Hatchet host must use https"
+# Limit for re-reading one timestamp's rows of a `since`-paged listing when they fill a whole page.
+TIE_GROUP_LIMIT = 10000
+
class HatchetRetryableError(Exception):
pass
@@ -64,6 +68,8 @@ class HatchetPage:
offset: int
rows: list[Any]
is_last_page: bool
+ # The `since` this page was read with, so a resume re-reads it.
+ since: str | None = None
@dataclasses.dataclass(frozen=True)
@@ -137,6 +143,15 @@ def resolve_connection(api_token: str, host: str | None = None, tenant_id: str |
return HatchetConnection(base_url=resolved_host, tenant_id=resolved_tenant)
+def _parse_datetime(value: Any) -> datetime | None:
+ if isinstance(value, str):
+ try:
+ return _to_datetime(datetime.fromisoformat(value))
+ except ValueError:
+ return None
+ return _to_datetime(value)
+
+
def _get_headers(api_token: str) -> dict[str, str]:
return {
"Authorization": f"Bearer {api_token}",
@@ -325,6 +340,27 @@ def _normalize_row(item: Any) -> dict[str, Any]:
return item
+def _assign_synthetic_ids(rows: list[Any], fields: tuple[str, ...]) -> list[dict[str, Any]]:
+ """Give each row an `id` hashed from `fields`.
+
+ Identical rows (the same line logged twice in one insert) get an ordinal, so they stay separate
+ rows. Identical rows are interchangeable, so the ordinal stays stable when the rows come back in
+ another order."""
+ counts: dict[str, int] = {}
+ for row in rows:
+ base = json.dumps([row.get(name) for name in fields], sort_keys=True, default=str)
+ ordinal = counts.get(base, 0)
+ counts[base] = ordinal + 1
+ row["id"] = hashlib.sha256(f"{base}\x1f{ordinal}".encode()).hexdigest()
+ return rows
+
+
+def _normalize_rows(items: list[Any], config: HatchetEndpointConfig) -> list[Any]:
+ if config.synthetic_id_fields:
+ return _assign_synthetic_ids(items, config.synthetic_id_fields)
+ return [_normalize_row(item) for item in items]
+
+
def get_rows(
api_token: str,
connection: HatchetConnection,
@@ -368,14 +404,11 @@ def get_rows(
else:
offset = 0
- # 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)
+ else iter(page.rows)
)
for row in rows:
batcher.batch(row)
@@ -383,7 +416,7 @@ def get_rows(
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))
+ resumable_source_manager.save_state(HatchetResumeConfig(offset=page.offset, since=page.since))
if batcher.should_yield(include_incomplete_chunk=True):
yield batcher.get_table()
@@ -410,7 +443,18 @@ def _iter_pages(
headers: dict[str, str],
logger: FilteringBoundLogger,
) -> Iterator[HatchetPage]:
- """Yield each non-empty page of an offset-paginated list."""
+ """Yield each non-empty page of a list, with its rows normalized."""
+ if config.pagination == "since":
+ yield from _iter_since_pages(session, connection, path, params, config, headers, logger)
+ return
+
+ if config.pagination == "none":
+ data = _fetch_page(session, _build_url(connection.base_url, path, params), headers, logger)
+ rows = _extract_rows(data, config)
+ if rows:
+ yield HatchetPage(offset=0, rows=_normalize_rows(rows, config), is_last_page=True)
+ return
+
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
@@ -433,13 +477,78 @@ def _iter_pages(
if isinstance(current_page, int) and isinstance(num_pages, int) and current_page >= num_pages:
is_last_page = True
- yield HatchetPage(offset=page_offset, rows=rows, is_last_page=is_last_page)
+ yield HatchetPage(
+ offset=page_offset,
+ rows=_normalize_rows(rows, config),
+ is_last_page=is_last_page,
+ since=params.get("since"),
+ )
if is_last_page:
return
offset = page_offset + config.page_size
+def _iter_since_pages(
+ session: requests.Session,
+ connection: HatchetConnection,
+ path: str,
+ params: dict[str, Any],
+ config: HatchetEndpointConfig,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+) -> Iterator[HatchetPage]:
+ """Yield the pages of a list that has no offset param, read in ascending `createdAt` order.
+
+ `since` is exclusive and many rows can share one timestamp, so each next window starts 1µs
+ before the last row's timestamp and drops the rows of that timestamp that were already yielded."""
+ since: str | None = params.get("since")
+ seen_at_boundary: set[str] = set()
+
+ while True:
+ page_params = {**params, "since": since} if since is not None else dict(params)
+ data = _fetch_page(session, _build_url(connection.base_url, path, page_params), headers, logger)
+ rows = _normalize_rows(_extract_rows(data, config), config)
+ if not rows:
+ return
+
+ is_last_page = len(rows) < config.page_size
+ read_whole_group = False
+ last_created_at = _parse_datetime(rows[-1].get("createdAt"))
+ if last_created_at is None:
+ # Without a timestamp the window can't advance, so stop rather than re-read the same page.
+ logger.warning(f"Hatchet: stopping {path} pagination, a row has no createdAt")
+ is_last_page = True
+ elif not is_last_page and _parse_datetime(rows[0].get("createdAt")) == last_created_at:
+ # The whole page shares one timestamp, so a moved window can't reach the rest of it. Read
+ # all rows of that timestamp in one larger request, then move past it.
+ group_params = {
+ **params,
+ "since": _format_datetime(last_created_at - timedelta(microseconds=1)),
+ "until": _format_datetime(last_created_at + timedelta(microseconds=1)),
+ "limit": TIE_GROUP_LIMIT,
+ }
+ data = _fetch_page(session, _build_url(connection.base_url, path, group_params), headers, logger)
+ rows = _normalize_rows(_extract_rows(data, config), config)
+ read_whole_group = True
+ if len(rows) >= TIE_GROUP_LIMIT:
+ logger.warning(f"Hatchet: {path} has more than {TIE_GROUP_LIMIT} rows at {last_created_at}")
+
+ new_rows = [row for row in rows if row.get("id") not in seen_at_boundary]
+ if new_rows:
+ yield HatchetPage(offset=0, rows=new_rows, is_last_page=is_last_page, since=since)
+
+ if is_last_page or last_created_at is None:
+ return
+
+ if read_whole_group:
+ since = _format_datetime(last_created_at)
+ seen_at_boundary = set()
+ else:
+ since = _format_datetime(last_created_at - timedelta(microseconds=1))
+ seen_at_boundary = {row["id"] for row in rows if _parse_datetime(row.get("createdAt")) == last_created_at}
+
+
def _iter_fan_out_rows(
session: requests.Session,
connection: HatchetConnection,
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 994a8f0fd64f..3b9f056490b9 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
@@ -41,6 +41,11 @@ class HatchetEndpointConfig:
# 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
+ # "offset" pages with `limit`/`offset`. "since" pages by advancing the `since` window to the last
+ # row's timestamp, for endpoints with no offset param. "none" is one unpaginated response.
+ pagination: Literal["offset", "since", "none"] = "offset"
+ # Row fields hashed into a synthetic `id`, for rows the API returns without an identifier.
+ synthetic_id_fields: tuple[str, ...] = ()
# `since` is required on the workflow-runs/tasks endpoint even for a full refresh. Retention windows
@@ -67,6 +72,15 @@ _FAN_OUT_INCREMENTAL_FIELDS: list[IncrementalField] = [
},
]
+_LOG_INCREMENTAL_FIELDS: list[IncrementalField] = [
+ {
+ "label": "createdAt",
+ "type": IncrementalFieldType.DateTime,
+ "field": "createdAt",
+ "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"}
@@ -152,6 +166,42 @@ HATCHET_ENDPOINTS: dict[str, HatchetEndpointConfig] = {
incremental_fields=[],
extra_params={"orderByField": "createdAt", "orderByDirection": "ASC"},
),
+ # Cron triggers of the tenant's workflows. No time filter, and the expression and enabled flag can
+ # change, so full refresh only. Paged by creation time so an edit can't shift rows between pages.
+ "crons": HatchetEndpointConfig(
+ name="crons",
+ path="/api/v1/tenants/{tenant}/workflows/crons",
+ partition_key="created_at",
+ incremental_fields=[],
+ extra_params={"orderByField": "createdAt", "orderByDirection": "ASC"},
+ ),
+ # Users with access to the tenant. The API returns every member in one response.
+ "tenant_members": HatchetEndpointConfig(
+ name="tenant_members",
+ path="/api/v1/tenants/{tenant}/members",
+ partition_key="created_at",
+ incremental_fields=[],
+ pagination="none",
+ ),
+ # Log lines emitted by tasks. The endpoint has no offset param, so pages advance the `since` window.
+ "logs": HatchetEndpointConfig(
+ name="logs",
+ path="/api/v1/stable/tenants/{tenant}/logs",
+ partition_key="createdAt",
+ incremental_fields=_LOG_INCREMENTAL_FIELDS,
+ default_incremental_field="createdAt",
+ supports_time_window=True,
+ default_lookback_days=30,
+ # A log line's createdAt is its insert transaction's start time, so a line can commit after a
+ # newer one was read. Re-read a short trailing window; merge dedupes on the synthetic id.
+ incremental_lookback=timedelta(minutes=5),
+ page_size=1000,
+ pagination="since",
+ # Log lines carry no id. A batch of lines shares one insert timestamp, so the message and
+ # metadata are part of the key.
+ synthetic_id_fields=("createdAt", "taskExternalId", "retryCount", "level", "message", "metadata"),
+ extra_params={"order_by_direction": "ASC"},
+ ),
# 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(
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 006d691af572..5e1818803017 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
@@ -90,6 +90,52 @@ def _row(row_id: str) -> dict[str, Any]:
return {"metadata": {"id": row_id, "createdAt": "2026-06-01T00:00:00Z", "updatedAt": "2026-06-01T00:00:00Z"}}
+def _log(created_at: str, message: str) -> dict[str, Any]:
+ return {
+ "createdAt": created_at,
+ "message": message,
+ "metadata": {"source": "worker"},
+ "taskExternalId": "11111111-1111-1111-1111-111111111111",
+ "retryCount": 0,
+ "attempt": 1,
+ "level": "INFO",
+ }
+
+
+_LOG_BOUNDARY = "2026-06-01T00:00:01.000000Z"
+_LOG_LATER = "2026-06-01T00:00:02.000000Z"
+
+# 998 lines at distinct timestamps, then two identical lines at the boundary timestamp. The next
+# window re-reads the boundary timestamp, which now also holds a third line.
+_SPLIT_GROUP_SCRIPT = [
+ ScriptedResponse(
+ json={
+ "rows": [_log(f"2026-06-01T00:00:00.{i:06d}Z", f"line {i}") for i in range(998)]
+ + [_log(_LOG_BOUNDARY, "dup"), _log(_LOG_BOUNDARY, "dup")],
+ "pagination": {},
+ }
+ ),
+ ScriptedResponse(
+ json={
+ "rows": [
+ _log(_LOG_BOUNDARY, "dup"),
+ _log(_LOG_BOUNDARY, "new"),
+ _log(_LOG_BOUNDARY, "dup"),
+ _log(_LOG_LATER, "last"),
+ ],
+ "pagination": {},
+ }
+ ),
+]
+
+# A full page that holds one timestamp only, so its group is read on its own with a larger limit.
+_SINGLE_TIMESTAMP_SCRIPT = [
+ ScriptedResponse(json={"rows": [_log(_LOG_BOUNDARY, f"line {i}") for i in range(1000)], "pagination": {}}),
+ ScriptedResponse(json={"rows": [_log(_LOG_BOUNDARY, f"line {i}") for i in range(1001)], "pagination": {}}),
+ ScriptedResponse(json={"rows": [_log(_LOG_LATER, "last")], "pagination": {}}),
+]
+
+
class TestGetRows:
@staticmethod
def _driver(host: str = "https://cloud.example") -> SourceDriver:
@@ -221,6 +267,78 @@ class TestGetRows:
(2, "run-1", "2026-06-01T00:00:00Z"),
]
+ @pytest.mark.parametrize(
+ "script,expected_rows,expected_since,expected_until,expected_limit",
+ [
+ (
+ _SPLIT_GROUP_SCRIPT,
+ 1002,
+ [None, "2026-06-01T00:00:00.999999Z"],
+ [None, None],
+ ["1000", "1000"],
+ ),
+ (
+ _SINGLE_TIMESTAMP_SCRIPT,
+ 1002,
+ [None, "2026-06-01T00:00:00.999999Z", "2026-06-01T00:00:01.000000Z"],
+ [None, "2026-06-01T00:00:01.000001Z", None],
+ ["1000", "10000", "1000"],
+ ),
+ ],
+ ids=["group_split_across_pages", "page_of_one_timestamp"],
+ )
+ def test_logs_advance_since_window_without_losing_or_repeating_lines(
+ self, script, expected_rows, expected_since, expected_until, expected_limit
+ ):
+ result = self._driver().run("logs", script)
+
+ assert result.raised is None
+ assert result.params("since") == expected_since
+ assert result.params("until") == expected_until
+ assert result.params("limit") == expected_limit
+ assert result.params("order_by_direction") == ["ASC"] * len(script)
+ rows = _collect(result.items)
+ assert len(rows) == expected_rows
+ assert len({row["id"] for row in rows}) == expected_rows
+ # The log's own metadata stays a column; it is not the resource envelope other endpoints lift.
+ assert json.loads(rows[0]["metadata"]) == {"source": "worker"}
+
+ def test_logs_resume_from_saved_since(self):
+ result = self._driver().run(
+ "logs",
+ [ScriptedResponse(json={"rows": [_log(_LOG_LATER, "last")], "pagination": {}})],
+ resume_state=HatchetResumeConfig(offset=0, since="2026-06-01T00:00:00.999999Z"),
+ should_use_incremental_field=True,
+ )
+
+ assert result.raised is None
+ assert result.params("since") == ["2026-06-01T00:00:00.999999Z"]
+ assert result.params("offset") == [None]
+
+ def test_tenant_members_read_in_one_request(self):
+ # The members endpoint has no pagination, so a full page must not trigger an offset request
+ # that would read every member again.
+ members = [
+ {
+ "metadata": {
+ "id": f"member-{i}",
+ "createdAt": "2026-06-01T00:00:00Z",
+ "updatedAt": "2026-06-01T00:00:00Z",
+ },
+ "user": {"email": f"user{i}@example.com"},
+ "role": "MEMBER",
+ }
+ for i in range(150)
+ ]
+ result = self._driver().run("tenant_members", [ScriptedResponse(json={"rows": members})])
+
+ assert result.raised is None
+ assert result.paths == ["/api/v1/tenants/tenant-1/members"]
+ assert result.params("offset") == [None]
+ rows = _collect(result.items)
+ assert len(rows) == 150
+ assert rows[0]["id"] == "member-0"
+
class TestFetchPage:
@pytest.mark.parametrize("allow_not_found", [True, False])