Skip to content

feat: Add optional float-roundtrip feature - #184

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

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

Conversation

@keelerm84

@keelerm84 keelerm84 commented Aug 6, 2026

Copy link
Copy Markdown
Member

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-roundtrip Cargo 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_roundtrip and launchdarkly-server-sdk-evaluation/float-roundtrip; the evaluation crate is bumped to 2.2.0 with default-features = false so disabling the feature actually turns off Go-matching float parsing in evaluations. Contract tests request float-roundtrip explicitly when using default-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.

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
keelerm84 marked this pull request as ready for review August 6, 2026 14:49
@keelerm84
keelerm84 requested a review from a team as a code owner August 6, 2026 14:49
@keelerm84
keelerm84 merged commit 465b231 into main Aug 6, 2026
16 checks passed
@keelerm84
keelerm84 deleted the mk/sdk-2859/float-roundtrip branch August 6, 2026 16:41
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