workflow: serialize run and step errors - #304
Merged
Merged
Conversation
fantix
force-pushed
the
fantix/serialized-errors
branch
from
August 25, 2026 16:53
b561e48 to
3f2844b
Compare
fantix
force-pushed
the
fantix/serialized-errors
branch
from
August 25, 2026 17:09
3f2844b to
a7b021e
Compare
fantix
force-pushed
the
fantix/serialized-errors
branch
from
August 26, 2026 18:40
a7b021e to
7794142
Compare
Preserve exception types, stacks, and causes across failed run and step events. Expose the plaintext run error classification and hydrate recorded failures for callers.
fantix
force-pushed
the
fantix/serialized-errors
branch
from
August 26, 2026 20:19
7794142 to
ac679ca
Compare
fantix
marked this pull request as ready for review
August 26, 2026 20:30
msullivan
approved these changes
Aug 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR serializes errors thrown in workflows and steps so that such errors are persisted in the world and can be dehydrated later to the caller. New public APIs:
return_value()of a failed workflowRunnow raises a newvercel.workflow.WorkflowRunFailedErrorerror instead ofRuntimeError@serializableto offer hydrate/dehydrate functions, or they will becomeRemoteError)vercel.workflow.RemoteErrorfor unknown cross-language errors as a lossless wrapper (for e2e test)Summary
run_failed,step_failed, andstep_retryingthrough the workflow payload codec.errorCodefield used by the TypeScript workflow protocol.WorkflowRunFailedError.Motivation
The Python SDK still used the old
{message, stack, code}error shape. Current TypeScript workflow packages expect serialized payloads, so TypeScript readers could lose Python failures and Python readers could receive raw serialized or encrypted data instead of an exception.Implementation
Error wire handling now lives in
error_serde.py. It uses the same dedicated tags as@workflow/corefor shared error classes and a genericErrortag for other exceptions.RemoteErrorpreserves TypeScript-only tags and fields, while@serializableremains the higher-priority path for custom exception classes.StructuredErrorhas been removed from run and step models. Error fields now retain their serialized payloads, andLocalWorldstores them without summarizing them. Encrypted error payloads resolve the run key before hydration.For callers:
awaitpoint;FatalErrorand retain it as__cause__;Run.return_value()raisesWorkflowRunFailedErrorwith the decoded failure aserror/__cause__and the plaintext classification aserror_code.Legacy Python string and
{message, stack, code}records remain readable. JavaScript non-Error thrown values are represented asRuntimeError(value). Python control-flow exceptions such asKeyboardInterruptcontinue to bypass workflow error serialization.Verification
uv run poe qa vercel-workflowuv run poe check-news-fragmentsLocalWorldtest proving a workflow can catch a step'sFatalErrorwith itsTypeErrorcause intact