Repository navigation
fix: Drop trackMetric events with a NaN or infinite metric value - #287
Merged
tanderson-ld merged 2 commits intoNov 30, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Contributor
|
bugbot review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit fcc9bb0. Configure here.
tanderson-ld
approved these changes
Nov 30, 2026
tanderson-ld
pushed a commit
that referenced
this pull request
Nov 30, 2026
🤖 I have created a release *beep* *boop* --- ## [7.19.1](launchdarkly-java-server-sdk-7.19.0...launchdarkly-java-server-sdk-7.19.1) (2026-11-30) ### Bug Fixes * Drop trackMetric events with a NaN or infinite metric value ([#287](#287)) ([319a441](319a441)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Release Please** bumps **launchdarkly-java-server-sdk** from **7.19.0** to **7.19.1** in the manifest, Gradle `version`, `Version.SDK_VERSION`, and **CHANGELOG**. > > The documented fix in this patch is **`trackMetric` no longer records events when the metric value is NaN or infinite**—those calls are ignored with a warning instead of being sent to LaunchDarkly ([#287](#287)). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 80f6da0. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> 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.
Requirements
LDClientEventTestrun on JDK 17 only)Related issues
No issue in this repository. Same failure mode as launchdarkly/go-server-sdk#520 and launchdarkly/ruby-server-sdk#498.
Describe the solution you've provided
LDClient#trackMetricpassesmetricValueto the event processor without checking it. ForNaNor±Infinity, Gson throws inEventOutputFormatterwhen the value is written. The exception is caught around the whole flush inDefaultEventProcessor, so the other events and the summaries in that batch are not delivered either.trackMetricnow checks the value after the existing context checks. For a non-finite value it logs a warning with the event name and does not record the event. Finite values are unchanged.The added test
trackMetricWithNonFiniteValueDoesNotSendEventcovers all three values. It fails without the change and passes with it.Describe alternatives you've considered
Checking in
EventOutputFormatter(shared internal library). That would also protect the payload, but the Go SDK fix put the check in the SDK, where it can warn at the call site.Additional context
This change was prepared with AI assistance (Claude Code).
Note
Overview
LDClient#trackMetricnow treats NaN and ±Infinity like invalid input: after the existing context checks it logs a warning (including the event name) and does not call the event processor, so bad metrics never reach JSON serialization.This avoids Gson failing during event flush and taking down the rest of the batch (other custom events and summaries). Valid finite metrics behave as before.
LDClientEventTestaddstrackMetricWithNonFiniteValueDoesNotSendEvent, asserting NaN and both infinities produce no events.Reviewed by Cursor Bugbot for commit fcc9bb0. Bugbot is set up for automated code reviews on this repo. Configure here.