Skip to content

Conversation

@shijiesheng
Copy link
Member

@shijiesheng shijiesheng commented Dec 1, 2025

What changed?

  • added WorkflowFailure that wraps the underlying exception
  • handled WorkflowFailure and respond the workflow failure event
  • reason is the Class name of the unwrapped exception, i.e. the cause; details are just a structured string representation of error message with the stack trace.
  • added cadence-web in integration test for debugging

Why?

add workflow failure handling.

How did you test it?

Integration test
Screenshot 2025-12-02 at 1 51 34 PM

Potential risks

Release notes

Documentation Changes

)
)
)
# TODO: handle cancellation error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# TODO: handle cancellation error
# TODO: handle cancellation error
# TODO: handle unknown error, fail decision task and try again instead of breaking the engine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually for other exceptions, they should be handled all together in the outter most layer WorkflowWorker.

result = self._task.result()
try:
result = self._task.result()
except (CancelledError, InvalidStateError) as e:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to wrap cancelled error? There are different scenarios to iterate on this.

if self._workflow_instance.is_done():
if self._workflow_instance.is_done():
try:
result = self._workflow_instance.get_result()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Maybe use the exception() method instead of try/catch to simplify the flow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've thought about this. The exception() actually would raise CancelledError rather than just return it. So there isn't any simplification for this. I still want to keep the WorkflowInstance's API easier: one way to get the result or throw an exception.

Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Signed-off-by: Shijie Sheng <liouvetren@gmail.com>
Decision(
fail_workflow_execution_decision_attributes=FailWorkflowExecutionDecisionAttributes(
failure=Failure(
reason=str(e),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason needs to be class name of the underlying exception for retry policy

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

if self._workflow_instance.is_done():
if self._workflow_instance.is_done():
try:
result = self._workflow_instance.get_result()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've thought about this. The exception() actually would raise CancelledError rather than just return it. So there isn't any simplification for this. I still want to keep the WorkflowInstance's API easier: one way to get the result or throw an exception.

)
)
)
# TODO: handle cancellation error
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually for other exceptions, they should be handled all together in the outter most layer WorkflowWorker.

@shijiesheng shijiesheng merged commit 899b9d8 into cadence-workflow:main Dec 3, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants