From d39aa14f7edcd4cd39291033dad0b839a8451b33 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Tue, 2 Dec 2025 11:23:42 -0800 Subject: [PATCH] fix: use CallbackError for non-successful callback --- src/aws_durable_execution_sdk_python/context.py | 9 +++++++-- tests/context_test.py | 5 ++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/aws_durable_execution_sdk_python/context.py b/src/aws_durable_execution_sdk_python/context.py index 30f6341..8728965 100644 --- a/src/aws_durable_execution_sdk_python/context.py +++ b/src/aws_durable_execution_sdk_python/context.py @@ -182,7 +182,7 @@ def result(self) -> T | None: if not checkpointed_result.is_existent(): msg = "Callback operation must exist" - raise CallbackError(msg) + raise CallbackError(message=msg, callback_id=self.callback_id) if ( checkpointed_result.is_failed() @@ -190,7 +190,12 @@ def result(self) -> T | None: or checkpointed_result.is_timed_out() or checkpointed_result.is_stopped() ): - checkpointed_result.raise_callable_error() + msg = ( + checkpointed_result.error.message + if checkpointed_result.error and checkpointed_result.error.message + else "Callback failed" + ) + raise CallbackError(message=msg, callback_id=self.callback_id) if checkpointed_result.is_succeeded(): if checkpointed_result.result is None: diff --git a/tests/context_test.py b/tests/context_test.py index e236dfb..3168683 100644 --- a/tests/context_test.py +++ b/tests/context_test.py @@ -18,7 +18,6 @@ ) from aws_durable_execution_sdk_python.context import Callback, DurableContext from aws_durable_execution_sdk_python.exceptions import ( - CallableRuntimeError, CallbackError, SuspendExecution, ValidationError, @@ -172,7 +171,7 @@ def test_callback_result_failed(): callback = Callback("callback5", "op5", mock_state) - with pytest.raises(CallableRuntimeError): + with pytest.raises(CallbackError): callback.result() @@ -231,7 +230,7 @@ def test_callback_result_timed_out(): callback = Callback("callback_timeout", "op_timeout", mock_state) - with pytest.raises(CallableRuntimeError): + with pytest.raises(CallbackError): callback.result()