🐛 Coerce workgraph node attributes to JSON-safe values on save#798
Open
elinscott wants to merge 1 commit into
Open
🐛 Coerce workgraph node attributes to JSON-safe values on save#798elinscott wants to merge 1 commit into
elinscott wants to merge 1 commit into
Conversation
Node attributes must be JSON-serializable, but workgraph data can carry non-serializable Python objects (e.g. enum defaults picked up from task function signatures), which made save_workgraph_data raise on store. Unwrap value-carrying objects recursively and fall back to str(). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
save_workgraph_dataassigns the serialized workgraph straight onto node attributes (workgraph_data,workgraph_data_short,workgraph_error_handlers). Node attributes must be JSON-serializable, but workgraph data can carry arbitrary Python objects that are not - the reproducing case is anEnumdefault picked up from a task function signature:Storing the process node then fails deep inside the storage backend with an unhelpful serialization error, far from the offending task definition.
Change
New
_ensure_json_safehelper applied to the three attribute payloads insave_workgraph_data. It walks the structure recursively and:None/bool/int/float/strand containers of them unchanged;json.dumpsas-is;obj.value, non-callable - coversEnummembers and similar wrappers) and recurses;str(value)as a last resort (a lossy-but-stored representation beats an engine crash at store time)Ordinary workgraphs (already JSON-safe) pass through untouched.
Notes