Repository navigation
Description
What are you really trying to do?
I'm trying to surface the rejection reason from a workflow_update_validator to the caller when using execute_update_with_start_workflow. The validator raises a meaningful exception (e.g., "reason is required"), but the caller receives Temporalio::Error::RPCError with code NOT_FOUND and message update "<uuid>" not found instead of Temporalio::Error::WorkflowUpdateFailedError with the validator's message as the cause.
Describe the bug
In lib/temporalio/internal/client/implementation.rb (line 188 in v1.4.1), there is a condition that determines whether to poll for the update outcome:
# If the user wants to wait until completed, we must poll until outcome if not already there
if input.wait_for_stage == Temporalio::Client::WorkflowUpdateWaitStage::COMPLETED && update_resp.outcome
update_resp.outcome = @client._impl.poll_workflow_update(...)
endThe comment says "if not already there," but the condition && update_resp.outcome is truthy when the outcome IS already present. It should be && !update_resp.outcome.
When a validator rejects an update:
- The multi-operation RPC returns
update_resp.outcomecontaining the rejection failure (this is correct — the server returns the outcome inline for validator rejections) - The buggy condition evaluates to
true(outcome is present, wait_for_stage is COMPLETED) poll_workflow_updateis called to fetch the outcome from history- Rejected updates are never written to workflow history, so the poll returns
NOT_FOUND - The
NOT_FOUNDpropagates asTemporalio::Error::RPCErrorinstead of the expectedWorkflowUpdateFailedError
If the condition were fixed to && !update_resp.outcome, the poll would be skipped when outcome is already present. The handle would be constructed with known_outcome: update_resp.outcome (line 251), and calling .result on it would correctly raise WorkflowUpdateFailedError with the validator's exception as the cause chain (via workflow_update_handle.rb line 60-61).
Minimal Reproduction
# frozen_string_literal: true
require "temporalio/client"
require "temporalio/testing/workflow_environment"
require "temporalio/worker"
require "temporalio/workflow"
require "securerandom"
require "logger"
class BugReproWorkflow < Temporalio::Workflow::Definition
def execute
Temporalio::Workflow.wait_condition { false }
end
workflow_update
def my_update(arg)
"result: #{arg}"
end
workflow_update_validator :my_update
def my_update_validator(arg)
raise "Invalid: reason is required" if arg.nil? || arg.empty?
end
end
Temporalio::Testing::WorkflowEnvironment.start_local(logger: Logger.new($stdout)) do |env|
task_queue = "tq-#{SecureRandom.uuid}"
worker = Temporalio::Worker.new(
client: env.client,
task_queue:,
workflows: [BugReproWorkflow],
)
worker.run do
# 1. Demonstrate successful update (works fine)
start_op = Temporalio::Client::WithStartWorkflowOperation.new(
BugReproWorkflow,
id: "wf-#{SecureRandom.uuid}",
task_queue:,
id_conflict_policy: Temporalio::WorkflowIDConflictPolicy::FAIL,
)
result = env.client.execute_update_with_start_workflow(
BugReproWorkflow.my_update, "hello",
start_workflow_operation: start_op,
)
puts "SUCCESS: Update result = #{result.inspect}"
# 2. Demonstrate validator rejection (triggers the bug)
start_op2 = Temporalio::Client::WithStartWorkflowOperation.new(
BugReproWorkflow,
id: "wf-#{SecureRandom.uuid}",
task_queue:,
id_conflict_policy: Temporalio::WorkflowIDConflictPolicy::FAIL,
)
begin
env.client.execute_update_with_start_workflow(
BugReproWorkflow.my_update, "",
start_workflow_operation: start_op2,
)
rescue Temporalio::Error::WorkflowUpdateFailedError => e
puts "EXPECTED: WorkflowUpdateFailedError with cause: #{e.cause&.message}"
rescue Temporalio::Error::RPCError => e
puts "BUG: Got RPCError instead of WorkflowUpdateFailedError"
puts " code: #{e.code}"
puts " message: #{e.message}"
puts " (The validator raised 'Invalid: reason is required' but it was swallowed)"
end
end
endExpected Behavior
SUCCESS: Update result = "result: hello"
EXPECTED: WorkflowUpdateFailedError with cause: Invalid: reason is required
Actual Behavior
SUCCESS: Update result = "result: hello"
BUG: Got RPCError instead of WorkflowUpdateFailedError
code: NOT_FOUND
message: update "some-uuid" not found
(The validator raised 'Invalid: reason is required' but it was swallowed)
Environment/Versions
- temporalio gem version: 1.4.1
- Ruby version: 3.2+ (reproduced on 4.0.1)
- OS/processor: macOS arm64 (Apple Silicon)
- Temporal server: 2.49.1
Status on main
The bug is present in the current main branch as of commit b0b6838 (June 4, 2026). The affected line has moved to line 220 in temporalio/lib/temporalio/internal/client/implementation.rb, but the logic is identical:
# If the user wants to wait until completed, we must poll until outcome if not already there
if input.wait_for_stage == Temporalio::Client::WorkflowUpdateWaitStage::COMPLETED && update_resp.outcome
update_resp.outcome = @client._impl.poll_workflow_update(...)
endNotably, the regular (non-with_start) update path at line 559 of the same file already has the correct negated condition (&& !resp.outcome), making this an inconsistency between the two code paths that was not caught when execute_update_with_start_workflow was added.
Proposed Fix
Line 220 of temporalio/lib/temporalio/internal/client/implementation.rb on main (line 188 in v1.4.1) — add ! to the condition:
- if input.wait_for_stage == Temporalio::Client::WorkflowUpdateWaitStage::COMPLETED && update_resp.outcome
+ if input.wait_for_stage == Temporalio::Client::WorkflowUpdateWaitStage::COMPLETED && !update_resp.outcomeThis aligns the Ruby SDK with:
- Its own comment: "poll until outcome if not already there"
- The existing correct condition already used in the regular (non-
with_start) update path at line 559 of the same file
Activity