sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

fix: fail task when update handler continues as new

Open Sakshamm-Goyal opened this issue 4 months ago • 1 comments

Fixes #436.

ContinueAsNewError derives from BaseException, so the update-handler task bypassed the normal update exception path and escaped as an unobserved detached-task exception. The update never completed and the workflow task was not failed.

Treat that control-flow exception as a workflow-task failure in the update path. On retry, the update can complete normally; it never continues the workflow from the update handler.

Regression coverage proves the baseline failure (an unhandled update task and timed-out update RPC) and verifies the retry completes after exactly one task failure.

Validation:

  • pytest tests/worker/test_workflow.py::test_workflow_update_continue_as_new_fails_task tests/worker/test_workflow.py::test_workflow_update_task_fails tests/worker/test_workflow.py::test_workflow_update_handlers_unhappy -q (3 passed)
  • ruff format --check temporalio/worker/_workflow_instance.py tests/worker/test_workflow.py
  • git diff --check

Note: whole-file Ruff reports seven existing diagnostics in unrelated lines of tests/worker/test_workflow.py.

Sakshamm-Goyal avatar Jul 31 '26 04:07 Sakshamm-Goyal

Corrected the inaccurate comment in 592e6e6. Continue-as-new is now documented as valid only from the top-level workflow; the update-handler path fails the workflow task rather than allowing that control-flow exception to escape. The change is comment-only and source compilation passes.

Sakshamm-Goyal avatar Jul 31 '26 20:07 Sakshamm-Goyal