mirror of
https://github.com/storytold/artcraft-services.git
synced 2026-11-23 10:50:58 +01:00
## Summary `url_utils::extension::Extension` derives `Hash` but implements `PartialEq` by hand, comparing only the bare extension (`value`). The derived `Hash` also hashes `dotted`, so two values that are equal can hash differently, which breaks the `Hash`/`Eq` contract `HashMap` and `HashSet` rely on. SonarCloud reports it as `rust:S7424` (CRITICAL bug): [AaGIexggqfo8xIwFiP92](https://sonarcloud.io/project/issues?id=storytold_artcraft-services&open=AaGIexggqfo8xIwFiP92). It can happen today with `Extension::from_static`, which takes both forms separately: `from_static("png", "PNG") == Extension::new("png")`, but their hashes differ. `Hash` is now implemented by hand and hashes `value` only, the same field `eq` compares. ## Tests - New `equal_extensions_hash_alike` test. It fails with the derived `Hash` and passes with this change. - `cargo test` for `url_utils` (33 + 2 doc tests) pass. I ran them on a standalone copy of the crate, with `url` pinned to the workspace's `2.5.8`, because the full workspace was not checked out locally. - `clippy --all-targets`: no findings in `extension.rs` (the crate's existing deprecation warnings elsewhere are unchanged). - Not run: the full workspace build. CI covers it. The same file in `storytold/artcraft` gets the same fix in storytold/artcraft#2802. No open PR here touches `url_utils`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Extension values that compare as equal now behave consistently when used in hashed collections, including values with differently formatted dotted notation. This improves predictable handling of equivalent extension values across operations that rely on hashing. <!-- end of auto-generated comment: release notes by coderabbit.ai -->