feat: Add optional float-roundtrip feature - #55
Merged
Conversation
Move serde_json's float_roundtrip behind a cargo feature named float-roundtrip, enabled by default so existing consumers see no change. This crate is where numeric flag values and numeric context attributes are actually parsed, but it never asked for float_roundtrip -- it only ever received it through Cargo feature unification from the Rust Server SDK. Since unification is additive and applies to the whole build, that also forced the feature on for every other serde_json user in a consumer's workspace, which a customer reported as an unwanted float-parsing cost. Owning the knob here lets a consumer opt out deliberately, and lets the SDK forward to it rather than relying on unification. 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 evaluation consistent with the other LaunchDarkly SDKs. Guard tests on FlagValue and AttributeValue assert that, gated on the feature so the opt-out configuration still builds; CI now also runs the test suite with --no-default-features. serde_json has offered float_roundtrip since 1.0.54, so the existing 1.0.57 minimum needs no bump.
keelerm84
marked this pull request as ready for review
August 4, 2026 20:02
beekld
self-requested a review
August 4, 2026 20:15
|
Is it your intention to remove the this feature from the Otherwise, I'm not sure how users of |
Member
Author
|
@beekld the intent is to also have the feature on the SDK. The SDK will disable all default features of this library by default, and then optionally enable it when the float_roundtrip feature is on. |
beekld
approved these changes
Aug 5, 2026
keelerm84
pushed a commit
that referenced
this pull request
Aug 6, 2026
🤖 I have created a release *beep* *boop* --- ## [2.2.0](2.1.4...2.2.0) (2026-08-06) ### Features * Add optional float-roundtrip feature ([#55](#55)) ([d584fc2](d584fc2)) ### Bug Fixes * Bump MSRV from 1.94 to 1.95 ([#53](#53)) ([34b3b12](34b3b12)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.
Move serde_json's float_roundtrip behind a cargo feature named
float-roundtrip, enabled by default so existing consumers see no change.
This crate is where numeric flag values and numeric context attributes are
actually parsed, but it never asked for float_roundtrip -- it only ever
received it through Cargo feature unification from the Rust Server SDK. Since
unification is additive and applies to the whole build, that also forced the
feature on for every other serde_json user in a consumer's workspace, which a
customer reported as an unwanted float-parsing cost.
Owning the knob here lets a consumer opt out deliberately, and lets the SDK
forward to it rather than relying on unification.
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 evaluation consistent with the other LaunchDarkly SDKs.
Guard tests on FlagValue and AttributeValue assert that, gated on the feature
so the opt-out configuration still builds; CI now also runs the test suite with
--no-default-features.
serde_json has offered float_roundtrip since 1.0.54, so the existing 1.0.57
minimum needs no bump.
Note
Medium Risk
Default behavior stays cross-SDK consistent, but opting out can change numeric flag/attribute parsing and evaluation versus other LaunchDarkly SDKs.
Overview
Introduces a
float-roundtripCargo feature (on by default) that forwards toserde_json/float_roundtrip, so this crate explicitly controls correctly-rounded JSON float parsing instead of inheriting it only via feature unification from the Rust Server SDK.Consumers can opt out with
default-features = falsewhen they prefer serde_json’s faster parser and accept possible cross-SDK numeric differences. README documents both features and the unification caveat.CI adds
cargo test --no-default-features.FlagValueandAttributeValuegain#[cfg(feature = "float-roundtrip")]tests that fractional JSON numbers deserialize to the samef64as Go’sencoding/json.Reviewed by Cursor Bugbot for commit efb6664. Bugbot is set up for automated code reviews on this repo. Configure here.