Description
Is your feature request related to a problem? Please describe.
When using the pydantic_data_converter
from temporalio.contrib.pydantic
(great feature by the way), it may happen that the payload cannot be decoded due to an incorrect payload. This results in a pydantic.ValidationError
being raised upon decoding the payload.
The current behavior is for these failures to be re-raised as a RuntimeError. Then the default behavior for these errors is to result in a Workflow Task Failed (Failed decoding arguments)
while keeping the workflow running. However, there is no way that such a workflow will ever complete with an incorrect payload.
In this issue https://community.temporal.io/t/force-workflow-failure-when-workflow-cannot-decode-arguments/10680/4 I found that you can specify which exceptions are treated as workflow failure, meaning there is a way to make the workflow fail directly upon workflow failures by using the experimental workflow_failure_exception_types
.
Specifying the pydantic.ValidationError does not work as it is re-raised by temporalio as a RuntimeError
workflow_failure_exception_types = [
pydantic.ValidationError, # does not work, is re-raised as RuntimeError upon decoding
]
async with Worker(
client,
task_queue="task-queue",
workflow_failure_exception_types=workflow_failure_exception_types,
):
I'm unsure about the side-effects of treating a RuntimeError as a workflow_failure_exception_types, because it is such a general exception.
Describe the solution you'd like
I would like to see a workflow failing directly upon 'Failed decoding arguments' while not having to specify a RuntimeError
as an error in workflow_failure_exception_types
.
I believe if the pydantic payload converter would raise a temporalio.exceptions.FailureError, would this then also fail the workflow? because that would seem most preferable.
Or otherwise, if the ValidationError would be re-raised instead of a RuntimeError, this would allow us to fail a workflow more specifically:
workflow_failure_exception_types = [
pydantic.ValidationError,
]