feat: Add optional float-roundtrip feature - #184
Merged
Conversation
The SDK has enabled serde_json's float_roundtrip dependency feature unconditionally since the initial beta release. Cargo feature unification is additive and applies to the whole build, so that turned the feature on for every other serde_json user in a consumer's workspace. A customer reported the resulting float-parsing cost and had to fork the SDK to get out of it. Move the behavior behind a cargo feature named float-roundtrip, enabled by default so nothing changes for consumers who do nothing. The feature forwards to both serde_json and the evaluation crate, and the evaluation crate is now pulled with default-features = false so that opting out actually takes effect rather than being silently undone by that crate's own default. float_roundtrip selects serde_json's correctly-rounded float parser, which is what makes fractional numbers land on the same f64 that Go's encoding/json produces and keeps numeric flag values and numeric context attributes consistent with the other LaunchDarkly SDKs. Verified against serde_json 1.0.150 that this is still load-bearing: with the feature off, 130.65331632653061 parses one unit in the last place low. The json_float_serialization_matches_go guard test is therefore gated on the feature, since CI builds several configurations with default features off. It was duplicated verbatim in reqwest.rs, which has nothing to do with float parsing; that copy is removed. The contract-test service depends on the SDK with default features off, so it now requests float-roundtrip explicitly -- the contract tests are our cross-SDK consistency check and need to run in the consistent configuration.
keelerm84
marked this pull request as ready for review
August 6, 2026 14:49
kinyoklion
approved these changes
Aug 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The SDK has enabled serde_json's float_roundtrip dependency feature
unconditionally since the initial beta release. Cargo feature unification is
additive and applies to the whole build, so that turned the feature on for
every other serde_json user in a consumer's workspace. A customer reported the
resulting float-parsing cost and had to fork the SDK to get out of it.
Move the behavior behind a cargo feature named float-roundtrip, enabled by
default so nothing changes for consumers who do nothing. The feature forwards
to both serde_json and the evaluation crate, and the evaluation crate is now
pulled with default-features = false so that opting out actually takes effect
rather than being silently undone by that crate's own default.
float_roundtrip selects serde_json's correctly-rounded float parser, which is
what makes fractional numbers land on the same f64 that Go's encoding/json
produces and keeps numeric flag values and numeric context attributes
consistent with the other LaunchDarkly SDKs. Verified against serde_json
1.0.150 that this is still load-bearing: with the feature off,
130.65331632653061 parses one unit in the last place low.
The json_float_serialization_matches_go guard test is therefore gated on the
feature, since CI builds several configurations with default features off. It
was duplicated verbatim in reqwest.rs, which has nothing to do with float
parsing; that copy is removed.
The contract-test service depends on the SDK with default features off, so it
now requests float-roundtrip explicitly -- the contract tests are our
cross-SDK consistency check and need to run in the consistent configuration.
Note
Medium Risk
Changes default dependency/feature wiring for numeric flag and context parsing; opting out can make evaluations differ from other LaunchDarkly SDKs by one ULP.
Overview
Moves serde_json’s correctly-rounded float parsing behind a new
float-roundtripCargo feature (still on by default), so consumers can opt out of the slower parser without forking the SDK.The feature forwards to
serde_json/float_roundtripandlaunchdarkly-server-sdk-evaluation/float-roundtrip; the evaluation crate is bumped to 2.2.0 withdefault-features = falseso disabling the feature actually turns off Go-matching float parsing in evaluations. Contract tests requestfloat-roundtripexplicitly when usingdefault-features = false.Docs add a Cargo features table and guidance for opting out; the Go float parity test is gated on the feature and deduplicated (removed from
reqwest.rs).Reviewed by Cursor Bugbot for commit 0be1eef. Bugbot is set up for automated code reviews on this repo. Configure here.