Repository navigation
fix(workflow): decode base64 bytes after JSON session resume - #7853
Closed
ninglinLiu wants to merge 11 commits into
Closed
ninglinLiu wants to merge 11 commits into
ninglinLiu wants to merge 11 commits into
Conversation
Event.output is typed Any, so Database/Sqlite JSON round-trips turn bytes into base64 strings. TypeAdapter(bytes) then utf-8-encodes the string. Prefer base64 decode when the parameter annotation is bytes. Fixes google#7852
copybara-service Bot
pushed a commit
that referenced
this pull request
Oct 30, 2026
Merge #7853 When a Workflow resumes from a JSON session store (DatabaseSessionService, SqliteSessionService), a finished node's `bytes` output comes back as its base64 text. The replayed output is now base64-decoded when the node declares a `bytes` output: a FunctionNode whose return annotation is `bytes`, `bytes | None` or a generator of either, or a node whose `output_schema` is `bytes` or `bytes | None`. Text that is not valid base64 replays unchanged. Live runs are unchanged. A producer with no return annotation still replays as base64 text, since the stored event does not record that the value was bytes. Part of #7852 PiperOrigin-RevId: 1010881203
Collaborator
|
Thank you @ninglinLiu for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit 81c3fe6. Closing this PR as the changes are now in the main branch. |
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.
Fixes
Fixes #7852
Summary
When a Workflow resumes from
DatabaseSessionService/SqliteSessionService, node outputs are restored from JSON-serializedEvents.Event.outputis typedAny, so pydantic'sser_json_bytes/val_json_bytesdo not round-tripbytes: they become base64 strings such as"AAE=".FunctionNodethen coerced those strings withTypeAdapter(bytes), which utf-8-encodes the string and yieldsb"AAE="instead ofb"\x00\x01".Changes
bytes/bytearrayand the value is still astr, preferbase64.b64decode(..., validate=True)beforeTypeAdapterTest plan
pytest tests/unittests/workflow/test_function_node_bytes_json_resume.py