fix(executor): make step and workflow JSONB writes BigInt-safe#1472
Open
joelorzet wants to merge 1 commit into
Open
fix(executor): make step and workflow JSONB writes BigInt-safe#1472joelorzet wants to merge 1 commit into
joelorzet wants to merge 1 commit into
Conversation
Step outputs that contain a BigInt (gas amounts, block numbers, token values from web3 steps) crashed when drizzle-orm serialized them to a JSONB column: PgJsonb.mapToDriverValue runs JSON.stringify, which throws on BigInt. The redacted output column was already protected, but the raw output_raw path (and step input) had no guard. Add a shared toJsonSafe helper that recursively normalizes BigInt, Uint8Array/Buffer, Map, Set, Date and circular refs to JSON-safe values, and apply it to the input, output, output_raw and workflow output writes at the persistence boundary so no non-serializable value can reach JSONB. Also harden batch-read-contract: when a call has no ABI outputs it returned the raw ethers Result (with BigInts) instead of serializing it.
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.
Step outputs that contain a BigInt (gas amounts, block numbers, token values from web3 steps) crashed when drizzle-orm serialized them to a JSONB column:
PgJsonb.mapToDriverValuerunsJSON.stringify, which throwsDo not know how to serialize a BigInt. The redactedoutputcolumn was already protected, but the rawoutput_rawpath (added later) and the stepinputcolumn had no guard, so any step returning a raw BigInt anywhere crashed at the persistence boundary.Fix
toJsonSafehelper (lib/utils/json-safe.ts) that recursively normalizes BigInt, Uint8Array/Buffer, Map, Set, Date and circular refs to JSON-safe values.input,output,output_rawand workflow-leveloutputwrites inlib/workflow/executor/logging.ts, so no non-serializable value can reach a JSONB column regardless of which step produced it.batch-read-contract: when a call has no ABI outputs it returned the raw ethersResult(carrying BigInts) instead of serializing it.Verification
Reproduced the exact crash and confirmed the fix against a real
workflow_execution_logs.output_rawwrite (thePgJsonb.mapToDriverValuesite): a raw-BigInt payload throws pre-fix and round-trips to strings post-fix. Unit tests covertoJsonSafe(BigInt, nested structures, Date, Buffer, Map/Set, circular refs) and the existing batch-read-contract suite passes.