From 294550f257b0eaf0f3ff6ea0c84f80d02a2dd611 Mon Sep 17 00:00:00 2001 From: Albert Callarisa Date: Tue, 10 Mar 2026 13:58:52 +0100 Subject: [PATCH 1/3] Use string for custom status Signed-off-by: Albert Callarisa --- durabletask/task.py | 6 +++--- durabletask/worker.py | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/durabletask/task.py b/durabletask/task.py index 83750ff..59f0c8f 100644 --- a/durabletask/task.py +++ b/durabletask/task.py @@ -70,13 +70,13 @@ def is_replaying(self) -> bool: pass @abstractmethod - def set_custom_status(self, custom_status: Any) -> None: + def set_custom_status(self, custom_status: str) -> None: """Set the orchestration instance's custom status. Parameters ---------- - custom_status: Any - A JSON-serializable custom status value to set. + custom_status: str + A custom status string to set. """ pass diff --git a/durabletask/worker.py b/durabletask/worker.py index 13f13d8..d6f6dd1 100644 --- a/durabletask/worker.py +++ b/durabletask/worker.py @@ -1093,10 +1093,18 @@ def current_utc_datetime(self, value: datetime): def is_replaying(self) -> bool: return self._is_replaying - def set_custom_status(self, custom_status: Any) -> None: - self._encoded_custom_status = ( - shared.to_json(custom_status) if custom_status is not None else None - ) + def set_custom_status(self, custom_status: str) -> None: + if custom_status is not None and not isinstance(custom_status, str): + import warnings + warnings.warn( + "Passing a non-str value to set_custom_status is deprecated and will be " + "removed in a future version. Serialize your value to a JSON string before calling.", + DeprecationWarning, + stacklevel=2, + ) + self._encoded_custom_status = shared.to_json(custom_status) + else: + self._encoded_custom_status = custom_status def create_timer(self, fire_at: Union[datetime, timedelta]) -> task.Task: return self.create_timer_internal(fire_at) From c5b83fa08a04dcc8f29548cd5a137513b6e74d35 Mon Sep 17 00:00:00 2001 From: Albert Callarisa Date: Wed, 11 Mar 2026 17:29:35 +0100 Subject: [PATCH 2/3] move warning import to the top Signed-off-by: Albert Callarisa --- durabletask/worker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/durabletask/worker.py b/durabletask/worker.py index d6f6dd1..b7e997d 100644 --- a/durabletask/worker.py +++ b/durabletask/worker.py @@ -8,6 +8,7 @@ import os import random import threading +import warnings from concurrent.futures import ThreadPoolExecutor from datetime import datetime, timedelta from threading import Event, Thread @@ -1095,7 +1096,6 @@ def is_replaying(self) -> bool: def set_custom_status(self, custom_status: str) -> None: if custom_status is not None and not isinstance(custom_status, str): - import warnings warnings.warn( "Passing a non-str value to set_custom_status is deprecated and will be " "removed in a future version. Serialize your value to a JSON string before calling.", From a273e876225155d4379e6dcc4f48156939f69c6a Mon Sep 17 00:00:00 2001 From: Albert Callarisa Date: Wed, 11 Mar 2026 17:29:40 +0100 Subject: [PATCH 3/3] Fix tests Signed-off-by: Albert Callarisa --- tests/durabletask/test_orchestration_e2e.py | 2 +- tests/durabletask/test_orchestration_e2e_async.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/durabletask/test_orchestration_e2e.py b/tests/durabletask/test_orchestration_e2e.py index f3cd56c..8711441 100644 --- a/tests/durabletask/test_orchestration_e2e.py +++ b/tests/durabletask/test_orchestration_e2e.py @@ -594,7 +594,7 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _): assert state.runtime_status == client.OrchestrationStatus.COMPLETED assert state.serialized_input is None assert state.serialized_output is None - assert state.serialized_custom_status == '"foobaz"' + assert state.serialized_custom_status == 'foobaz' def test_now_with_sequence_ordering(): diff --git a/tests/durabletask/test_orchestration_e2e_async.py b/tests/durabletask/test_orchestration_e2e_async.py index b2f3003..fa09a47 100644 --- a/tests/durabletask/test_orchestration_e2e_async.py +++ b/tests/durabletask/test_orchestration_e2e_async.py @@ -481,4 +481,4 @@ def empty_orchestrator(ctx: task.OrchestrationContext, _): assert state.runtime_status == OrchestrationStatus.COMPLETED assert state.serialized_input is None assert state.serialized_output is None - assert state.serialized_custom_status == '"foobaz"' + assert state.serialized_custom_status == 'foobaz'