Preserve JSON input object order#590
Draft
dnagoda wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 6, 2026
Function-runner parses JSON inputs into serde_json::Value and reserializes them before passing bytes to the WASM. With serde_json's default map implementation, this sorts object keys lexicographically, which can change JS behavior that depends on Object.keys() ordering for fallback logic.\n\nEnable serde_json's preserve_order feature so JSON input object key order is retained, and add a regression test covering nested metafield-like message objects. This keeps function-rerunner parity closer to production inputs for Checkout Blocks discount functions.\n\nVerified with:\n- cargo test json_input_preserves_object_key_order_in_raw_bytes\n- cargo build --release\n- cargo test\n- Rerunning the 17 discount localized-message mismatch rows with the fixed release runner produced full semantic matches. Assisted-By: devx/c659e918-9568-4750-b122-e3890447348a
02f146c to
da2da97
Compare
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.
📚 Stack (bottom → top)
--batch-full-outputopt-inWhy
function-runnerparses each JSON input intoserde_json::Valueandreserializes it to bytes before handing it to the Wasm module. With
serde_json's default map, object keys are reordered lexicographically. JSfunctions that rely on
Object.keys()ordering can then behave differently underreplay than in production, breaking parity.
What
serde_json'spreserve_orderfeature so input object key order isretained end-to-end through the runner.
in the ordering guarantee.
This brings
function-rerunnerinputs closer to real production bytes.Testing
cargo test json_input_preserves_object_key_order_in_raw_bytescargo build --releasecargo testrunner → full semantic matches.