Skip to content

feat: Add optional float-roundtrip feature - #55

Merged
keelerm84 merged 1 commit into
mainfrom
mk/sdk-2858/float-roundtrip
Aug 6, 2026
Merged

feat: Add optional float-roundtrip feature#55
keelerm84 merged 1 commit into
mainfrom
mk/sdk-2858/float-roundtrip

Conversation

@keelerm84

@keelerm84 keelerm84 commented Aug 4, 2026

Copy link
Copy Markdown
Member

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-roundtrip Cargo feature (on by default) that forwards to serde_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 = false when 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. FlagValue and AttributeValue gain #[cfg(feature = "float-roundtrip")] tests that fractional JSON numbers deserialize to the same f64 as Go’s encoding/json.

Reviewed by Cursor Bugbot for commit efb6664. Bugbot is set up for automated code reviews on this repo. Configure here.

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
keelerm84 marked this pull request as ready for review August 4, 2026 20:02
@keelerm84
keelerm84 requested a review from a team as a code owner August 4, 2026 20:02
@beekld
beekld self-requested a review August 4, 2026 20:15
@beekld

beekld commented Aug 4, 2026

Copy link
Copy Markdown

Is it your intention to remove the this feature from the rust-server-sdk Cargo.toml?

Otherwise, I'm not sure how users of rust-server-sdk are going to control this, since they only get rust-server-sdk-evaluation transitively. I was wondering if we should just add the new feature to the server SDK instead, although I admit it's weird to have that library changing this one's behavior in such an indirect way.

@keelerm84

Copy link
Copy Markdown
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.

@keelerm84
keelerm84 merged commit d584fc2 into main Aug 6, 2026
8 checks passed
@keelerm84
keelerm84 deleted the mk/sdk-2858/float-roundtrip branch August 6, 2026 14:28
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants