fix(vars): ignore mapping key order when deduplicating deltas

BL
3d ago
+59-10

Related to #7253 (the dictionary key ordering case).

When an uncached computed value returns the same dictionary entries in a different insertion order, _delta_value_key hashes a different JSON string. That sends another delta even though the value hasn't changed.

The comparison key now uses sorted JSON keys, including for nested dictionaries. The payload sent to the browser is unchanged. I added a regression test covering reordered nested mappings and a value that genuinely changes.

Testing

  • Confirmed the original helper produces different keys for reordered mappings, while the updated helper produces the same key
  • Compiled both changed Python files with python3 -m py_compile
  • The full pytest suite wasn't run on the production host; repository CI can exercise the added test

All Submissions

  • Followed the contribution guidelines
  • Checked for an existing PR covering this part of #7253

Type of change

  • Bug fix (non-breaking)

Changes To Core Features

  • Explained the change above
  • Added a regression test
  • Ran focused before/after checks

This contribution was prepared with AI assistance.