Skip to content

Preserve JSON input object order#590

Draft
dnagoda wants to merge 1 commit into
dc.batch-modefrom
dc.batch-2-preserve-json-order
Draft

Preserve JSON input object order#590
dnagoda wants to merge 1 commit into
dc.batch-modefrom
dc.batch-2-preserve-json-order

Conversation

@dnagoda

@dnagoda dnagoda commented Jul 6, 2026

Copy link
Copy Markdown

📚 Stack (bottom → top)

  1. Add batch mode for JSONL function runs #595 Add batch mode for processing multiple inputs via JSONL
  2. Preserve JSON input object order #590 Preserve JSON input object order
  3. Refine batch failure handling #591 Refine batch failure handling
  4. Reuse the compiled provider across runs #592 Reuse the compiled provider across runs
  5. Compute humanized bytes lazily #593 Compute humanized bytes lazily
  6. Add minimal batch output with --batch-full-output opt-in #594 Add minimal batch output with --batch-full-output opt-in

Stacked PRs — review bottom-up.


Why

function-runner parses each JSON input into serde_json::Value and
reserializes it to bytes before handing it to the Wasm module. With
serde_json's default map, object keys are reordered lexicographically. JS
functions that rely on Object.keys() ordering can then behave differently under
replay than in production, breaking parity.

What

  • Enable serde_json's preserve_order feature so input object key order is
    retained end-to-end through the runner.
  • Add a regression test covering nested, metafield-like message objects to lock
    in the ordering guarantee.

This brings function-rerunner inputs closer to real production bytes.

Testing

  • cargo test json_input_preserves_object_key_order_in_raw_bytes
  • cargo build --release
  • cargo test
  • Re-ran the 17 discount localized-message mismatch rows with the fixed release
    runner → full semantic matches.

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
@dnagoda dnagoda force-pushed the dc.batch-2-preserve-json-order branch from 02f146c to da2da97 Compare July 6, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant