From ddafe6beab333508fafd3af1975bebaddf94166a Mon Sep 17 00:00:00 2001 From: kanatoko Date: Sat, 21 Feb 2026 14:27:24 +0700 Subject: [PATCH 1/2] Fix error handling and serialization in workflow errors --- lib/temporal/workflow/errors.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/temporal/workflow/errors.rb b/lib/temporal/workflow/errors.rb index f13f03bf..cfbcc381 100644 --- a/lib/temporal/workflow/errors.rb +++ b/lib/temporal/workflow/errors.rb @@ -21,8 +21,8 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr message = "#{error_type}: #{failure.message}" exception_class = default_exception_class end + details = failure.application_failure_info.details begin - details = failure.application_failure_info.details exception_or_message = converter.from_details_payloads(details) # v1 serialization only supports StandardErrors with a single "message" argument. # v2 serialization supports complex errors using our converters to serialize them. @@ -34,6 +34,12 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr end rescue StandardError => deserialization_error message = "#{exception_class}: #{message}" + serialized_error = + if details && details.respond_to?(:payloads) && details.payloads.first && details.payloads.first.respond_to?(:data) + details.payloads.first.data + else + nil + end exception = default_exception_class.new(message) Temporal.logger.error( "Could not instantiate original error. Defaulting to StandardError. Make sure the worker running " \ @@ -43,7 +49,7 @@ def self.generate_error(failure, converter, default_exception_class = StandardEr "your error's initializer takes something other than exactly one positional argument.", { original_error: error_type, - serialized_error: details.payloads.first.data, + serialized_error: serialized_error, instantiation_error_class: deserialization_error.class.to_s, instantiation_error_message: deserialization_error.message, }, From a007068fb858c5d5dc8d6558324926de45e729b2 Mon Sep 17 00:00:00 2001 From: kanatoko Date: Sat, 21 Feb 2026 07:31:41 +0000 Subject: [PATCH 2/2] fix: address additional issues potentially uninitialized local variable --- lib/temporal/saga/concern.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/temporal/saga/concern.rb b/lib/temporal/saga/concern.rb index 5cc36f7b..5e386c6d 100644 --- a/lib/temporal/saga/concern.rb +++ b/lib/temporal/saga/concern.rb @@ -5,6 +5,7 @@ module Temporal module Saga module Concern def run_saga(&block) + saga = nil saga = Temporal::Saga::Saga.new(workflow) block.call(saga) @@ -14,7 +15,7 @@ def run_saga(&block) logger.error("Saga execution aborted", { error: error.inspect }) logger.debug(error.backtrace.join("\n")) - saga.compensate + saga.compensate if saga Result.new(false, error) end