Skip to content

Fix order-dependent hashing in OpenAPIObjectContainer and OpenAPIValueContainer - #195

Merged
simonjbeaumont merged 4 commits into
apple:mainfrom
andrii-vysotskyi-maudau:fix/object_container_hash
Aug 20, 2026
Merged

Fix order-dependent hashing in OpenAPIObjectContainer and OpenAPIValueContainer#195
simonjbeaumont merged 4 commits into
apple:mainfrom
andrii-vysotskyi-maudau:fix/object_container_hash

Conversation

@andrii-vysotskyi-maudau

@andrii-vysotskyi-maudau andrii-vysotskyi-maudau commented May 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

OpenAPIObjectContainer and OpenAPIValueContainer’s hash(into:) depends on dictionary iteration order. This can cause equal values to produce different hashes, violating Hashable requirements.

Modifications

Updated hash(into:) to sort keys before hashing.

Result

Equal objects are now guaranteed to produce same hash value.

Test Plan

Added a regression test verifying hash stability.

@andrii-vysotskyi-maudau

Copy link
Copy Markdown
Contributor Author

Hi @simonjbeaumont - I noticed you were active on some recent PRs. If you have time, would you mind taking a look at this one? I’d appreciate any feedback. Thanks!

@andrii-vysotskyi-maudau andrii-vysotskyi-maudau changed the title Fix order-dependent hashing in OpenAPIObjectContainer Fix order-dependent hashing in OpenAPIObjectContainer and OpenAPIValueContainer Aug 14, 2026

@simonjbeaumont simonjbeaumont left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@simonjbeaumont simonjbeaumont added the 🔨 semver/patch No public API change. label Aug 20, 2026
@simonjbeaumont
simonjbeaumont enabled auto-merge (squash) August 20, 2026 14:48
@simonjbeaumont
simonjbeaumont merged commit 7a89b4f into apple:main Aug 20, 2026
51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants