Repository navigation
fix: Prevent the C API from swapping track data and metric values - #639
Merged
Merged
Conversation
Generated-by: termag
kinyoklion
marked this pull request as ready for review
November 4, 2026 22:09
beekld
approved these changes
Nov 4, 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.
Summary
LDServerSDK_TrackMetricandLDClientSDK_TrackMetricpassed the metric value and the data toTrackin the wrong order. The implicit conversions betweenValueanddoublelet the call compile, so the event carried the metric value as its data, and the data converted to a number (usually 0) as its metric value. This affects every caller of these two C functions, including the Lua server-side SDK. The C++ API andLDServerSDK_TrackMetric_WithHookContextalready pass the values in the right order.Tested with new server and client C binding tests, which fail before this change and pass after it. The full server and client unit test suites pass.
Opened from termag
Note
Overview
LDClientSDK_TrackMetricandLDServerSDK_TrackMetricwere forwarding arguments to the underlyingTrackcall in the wrong order, so the numeric metric was stored as event data and theLDValuepayload was treated as the metric (often becoming0via implicit conversion). The C bindings now match the C++ API and the existingLDServerSDK_TrackMetric_WithHookContextpath: data first, thenmetric_value.Regression coverage adds a client test that subclasses
Clientto assert the received data and metric, and a server hook test that readsLDTrackSeriesContext_DataandLDTrackSeriesContext_MetricValueafterLDServerSDK_TrackMetric.Reviewed by Cursor Bugbot for commit f9f68b6. Bugbot is set up for automated code reviews on this repo. Configure here.