Repository navigation
fix(serialization): support set and frozenset generic containers in JsonDataConverter #310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
andystaples
merged 5 commits into
microsoft:main
from
hardikkaurani:fix/serialization-generic-sets
Oct 30, 2026
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3567d1a
fix(serialization): support set and frozenset generic containers in J…
hardikkaurani 2bedbec
fix(serialization): deterministic set ordering, opt-in set reconstruc…
hardikkaurani 6c924e5
fix(serialization): stabilize nested set ordering
hardikkaurani ecf8270
fix(serialization): simplify set serialization by emitting sorted can…
hardikkaurani 130a310
Merge branch 'main' into fix/serialization-generic-sets
hardikkaurani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Use a deterministic total ordering even when native sorting succeeds
The new fallback fixes the non-orderable dataclass case, but
sorted(items)can succeed without producing a deterministic order. Frozensets compare by subset relationships, not a total order, so disjoint frozensets keep hash-dependent iteration order and never reach the fallback.For example:
In separate processes, I get:
PYTHONHASHSEED=1:[["alpha"], ["gamma"], ["beta"]]PYTHONHASHSEED=2:[["gamma"], ["alpha"], ["beta"]]This still violates the deterministic-serialization contract across worker processes and replay. Please use a deterministic total ordering based on recursively encoded values rather than relying on native sorting merely because it does not raise, and extend the cross-process regression to nested frozensets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for identifying this edge case, andystaples.
I have updated the set serialization ordering in
durabletask/serialization.pyto use a dedicated deterministic total-ordering sort key (_deterministic_set_sort_key) based on recursively encoded values rather than relying on native sorting to succeed. This ensures disjoint and nested frozenset values establish a deterministic total order across processes and replays, while preserving numerical ordering for numeric sets.I also updated and extended
test_set_serialization_deterministic_across_hash_seedsintests/durabletask/test_serialization.pyto exercise disjoint frozensets (Case A), nested frozensets across multiple levels (Case B), and unorderable frozen dataclasses (Case C) across multiplePYTHONHASHSEEDvalues (0,1,2,42,999) using portable repository-relative path resolution.Validation Results
pytest tests/durabletask/test_serialization.py: 56 passedpytest tests/durabletask/test_data_converter.py: 35 passedpytest tests/durabletask/test_data_converter_roundtrip.py: 48 passedpytest tests/durabletask/test_type_discovery.py: 37 passednox -s lint: passed (flake8 clean, 0 issues)pyright durabletask/serialization.py: 0 errors, 0 warningsnox -s functions_unit-3.13: 406 passedThe fix is pushed to
fix/serialization-generic-setsin commit6c924e5.