Skip to content

Commit 026c90c

Browse files
Align workflow task history token field
1 parent 6e7015d commit 026c90c

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/durable_workflow/client.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,8 @@ async def workflow_task_history(
20432043
self,
20442044
*,
20452045
task_id: str,
2046-
page_token: str,
2046+
next_history_page_token: str | None = None,
2047+
page_token: str | None = None,
20472048
lease_owner: str,
20482049
workflow_task_attempt: int,
20492050
) -> Any:
@@ -2052,8 +2053,15 @@ async def workflow_task_history(
20522053
Worker-plane endpoint. The first page of history is delivered inline
20532054
with the workflow task; this endpoint fetches subsequent pages.
20542055
"""
2056+
if next_history_page_token is None:
2057+
next_history_page_token = page_token
2058+
elif page_token is not None and page_token != next_history_page_token:
2059+
raise ValueError("page_token must match next_history_page_token when both are provided")
2060+
if next_history_page_token is None:
2061+
raise ValueError("next_history_page_token is required")
2062+
20552063
body: dict[str, Any] = {
2056-
"page_token": page_token,
2064+
"next_history_page_token": next_history_page_token,
20572065
"lease_owner": lease_owner,
20582066
"workflow_task_attempt": workflow_task_attempt,
20592067
}

src/durable_workflow/worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ async def _run_workflow_task_core(self, task: dict[str, Any]) -> list[dict[str,
393393
try:
394394
page_data = await self.client.workflow_task_history(
395395
task_id=task_id,
396-
page_token=next_page_token,
396+
next_history_page_token=next_page_token,
397397
lease_owner=self.worker_id,
398398
workflow_task_attempt=attempt,
399399
)

tests/fixtures/control-plane/workflow-task-history-parity.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"method": "POST",
77
"path": "/worker/workflow-tasks/workflow-task-231/history",
88
"body": {
9-
"page_token": "history-page-2",
9+
"next_history_page_token": "history-page-2",
1010
"lease_owner": "polyglot-worker-231",
1111
"workflow_task_attempt": 2
1212
}
@@ -15,7 +15,7 @@
1515
"task_id": "workflow-task-231",
1616
"lease_owner": "polyglot-worker-231",
1717
"workflow_task_attempt": 2,
18-
"page_token": "history-page-2",
18+
"next_history_page_token": "history-page-2",
1919
"last_sequence": 4,
2020
"next_page_token": "history-page-3"
2121
},
@@ -52,7 +52,7 @@
5252
"method": "workflow_task_history",
5353
"kwargs": {
5454
"task_id": "workflow-task-231",
55-
"page_token": "history-page-2",
55+
"next_history_page_token": "history-page-2",
5656
"lease_owner": "polyglot-worker-231",
5757
"workflow_task_attempt": 2
5858
}

0 commit comments

Comments
 (0)