Repository navigation
fix: Record no variation and a WRONG_TYPE reason in events when a typed evaluation has the wrong type - #554
Merged
Merged
Conversation
…ed evaluation has the wrong type Generated-by: termag
There was a problem hiding this comment.
Automated risk review (dry run): Low
This PR would be automatically approved.
Why: The change is a small, spec-aligned fix in LDClientVariation.swift and FeatureFlag.swift so wrong-type typed evaluations record no variation and a WRONG_TYPE reason, with covering tests in LDClientSpec.swift.
If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.
Sent by Cursor Approval Agent: Dry-Run PR Approver
Co-Authored-By: Claude Opus 5.5 <[email protected]>
kinyoklion
approved these changes
Nov 17, 2026
Co-Authored-By: Claude Opus 5.5 <[email protected]>
abelonogov-ld
added a commit
that referenced
this pull request
Nov 18, 2026
… tier 3 name in the wrong-type evaluation test from #554 Co-authored-by: Cursor <[email protected]>
tanderson-ld
pushed a commit
that referenced
this pull request
Nov 23, 2026
🤖 I have created a release *beep* *boop* --- ## [11.8.1](11.8.0...11.8.1) (2026-11-23) ### Bug Fixes * avoid Foundation's back-deployed Date comparison operators ([#575](#575)) ([1e18137](1e18137)) * Record no variation and a WRONG_TYPE reason in events when a typed evaluation has the wrong type ([#554](#554)) ([d76e12e](d76e12e)) * Start the primary environment first, then secondary environments by name ([#572](#572)) ([30856c4](30856c4)) --- 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 11.8.1** bumps the SDK version from `11.8.0` to `11.8.1` across packaging and metadata (Release Please manifest, `LaunchDarkly.podspec`, Xcode `MARKETING_VERSION` / dylib versions, `ReportingConsts.sdkVersion`, and README SPM pin). > > The changelog for this patch documents three **bug fixes** shipped in the release: > > **Debug events on newer Apple SDKs:** `FeatureFlag.shouldCreateDebugEvents` no longer compares `Date` values with `<=` / `>=`. It uses `timeIntervalSinceReferenceDate` instead, avoiding crashes when Foundation’s back-deployed Date operators are missing on some iOS 27.2 beta builds. > > **Typed evaluation analytics:** When a flag value cannot be decoded to the requested type, evaluations now emit **`WRONG_TYPE`** with **no variation index** in both the returned detail and recorded flag events (via `withEvaluationResult(variation: nil, …)`). > > **Multi-environment startup order:** `LDClient.start` initializes the **primary** environment first, then **secondary** environments in **stable alphabetical order by name**, so client creation and plugin registration are deterministic across launches. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4ad6acb. 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> Co-authored-by: LaunchDarklyReleaseBot <[email protected]>
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
When a typed variation method (
boolVariation,intVariation,doubleVariation,stringVariationand their detail forms) got a flag value of the wrong type, the SDK returned the default value with aWRONG_TYPEreason. The analytics event recorded the default value, but it took its variation and reason from the stored flag, so the feature event and the summary counter reported the flag's variation and its original reason.On a type mismatch the event now gets a copy of the flag with no variation and the
WRONG_TYPEreason. The copy keeps the flag version, tracking and the debug date. The feature event and the summary counter read the variation and reason from that flag, so both are correct. This matches the evaluation spec.The new specs are in
LDClientSpec.swift, in the context "flag value has the wrong type". They were not run locally because the SDK builds only on Apple platforms.Opened from termag
Note
Overview
Fixes flag evaluation analytics when a typed variation call fails because the stored flag value is the wrong type. The app already got the default value with a
WRONG_TYPEreason and no variation; events were still built from the stored flag, so variation and reason in feature events and summary counters could disagree with the evaluation detail.variationDetailInternalnow tracks aneventFeatureFlagfor reporting. On decode failure it replaces that with a copy from the newFeatureFlag.withEvaluationResult(variation:reason:), clearing variation and setting theWRONG_TYPEreason while keeping version and tracking fields.recordFlagEvaluationEventsreceives that copy instead of the raw store flag.Tests in
LDClientSpeccover the detail result and the event payload for the wrong-type case.Reviewed by Cursor Bugbot for commit 6727d0a. Bugbot is set up for automated code reviews on this repo. Configure here.