Skip to content

Do not wrap workflow-failure exceptions from converters in workflows #882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

666ares
Copy link

@666ares 666ares commented Jun 1, 2025

What was changed

Fail workflow upon pydantic.ValidationError when using the pydantic_data_converter, so that the user can pass that specific exception type to workflow_failure_exception_types in order for the workflow to fail instead of keeping it running, since there is no way that such a workflow will ever complete with an incorrect payload.

Checklist

  1. Closes [Feature Request] Fail workflow upon pydantic.ValidationError when using the pydantic_data_converter #815

  2. How was this tested:
    tests/worker/test_workflow::test_workflow_fail_on_bad_input was updated to check the right exception message.
    test/worker/test_workflow::test_workflow_fail_on_bad_pydantic_input was added to check that the workflow indeed fails when a Pydantic model can't be validated.

  3. Any docs updates needed?
    No.

@666ares 666ares requested a review from a team as a code owner June 1, 2025 20:58
@CLAassistant
Copy link

CLAassistant commented Jun 1, 2025

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


José A. Pastor seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

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

LGTM, @dandavison - thoughts?

@@ -1774,6 +1774,8 @@ def _convert_payloads(
# Don't wrap payload conversion errors that would fail the workflow
raise
except Exception as err:
if self._is_workflow_failure_exception(err):
Copy link
Member

Choose a reason for hiding this comment

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

Technically this has backwards compatibility concerns since it changes existing behavior based on raised exception, but I think it's ok in this instance.

But can we change the PR title to be a bit more generic so when it shows up in release notes it doesn't look like it's Pydantic specific? Maybe something like "do not wrap workflow-failure exceptions from converters in workflows"?

@666ares 666ares changed the title Allow pydantic validation error to fail workflow Do not wrap workflow-failure exceptions from converters in workflows Jun 2, 2025
@cretz
Copy link
Member

cretz commented Jun 4, 2025

@666ares - I am updating your branch with main and will merge if/when CI passes (can ignore some flakes there)

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.

[Feature Request] Fail workflow upon pydantic.ValidationError when using the pydantic_data_converter
4 participants