Problem
statsig-rust (since v0.15.1) unconditionally enables serde_json's preserve_order feature:
[dependencies.serde_json]
version = "1.0.143"
features = [
"float_roundtrip",
"raw_value",
"preserve_order",
]
Due to Cargo's feature unification, this changes serde_json::Value's internal Map from BTreeMap (alphabetically sorted keys) to IndexMap (insertion-order keys) for every crate in the consumer's workspace — not just statsig-rust.
Impact
Adding statsig-rust to any crate in a workspace silently changes serialization behavior for all other crates:
- JSON output key ordering changes from alphabetical to insertion order
- Test snapshots break
- Generated files (e.g. OpenAPI specs) produce unnecessary diffs
- Deterministic serialization assumptions break
These issues are extremely hard to trace back to a transitive dependency. Having this side effect can definitely make customers less likely to adopt this crate since it will have workspace-wide side effects to one of the most widely used rust crates.
Suggestion
Ideally, remove the preserve_order dependency entirely by rewriting any code that relies on insertion-order JSON keys. If that's not feasible, please make it opt-in via a feature flag instead:
[features]
preserve_order = ["serde_json/preserve_order"]
[dependencies.serde_json]
version = "1.0.143"
features = [
"float_roundtrip",
"raw_value",
]
Problem
statsig-rust(since v0.15.1) unconditionally enablesserde_json'spreserve_orderfeature:Due to Cargo's feature unification, this changes serde_json::Value's internal Map from BTreeMap (alphabetically sorted keys) to IndexMap (insertion-order keys) for every crate in the consumer's workspace — not just statsig-rust.
Impact
Adding statsig-rust to any crate in a workspace silently changes serialization behavior for all other crates:
These issues are extremely hard to trace back to a transitive dependency. Having this side effect can definitely make customers less likely to adopt this crate since it will have workspace-wide side effects to one of the most widely used rust crates.
Suggestion
Ideally, remove the
preserve_orderdependency entirely by rewriting any code that relies on insertion-order JSON keys. If that's not feasible, please make it opt-in via a feature flag instead: