Skip to content

fix: Record no variation and a WRONG_TYPE reason in events when a typed evaluation has the wrong type - #554

Merged
keelerm84 merged 3 commits into
v11from
mk/SDK-3636/wrong-type-events
Nov 17, 2026
Merged

keelerm84 merged 3 commits into
v11from
mk/SDK-3636/wrong-type-events

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Summary

When a typed variation method (boolVariation, intVariation, doubleVariation, stringVariation and their detail forms) got a flag value of the wrong type, the SDK returned the default value with a WRONG_TYPE reason. 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_TYPE reason. 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_TYPE reason 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.

variationDetailInternal now tracks an eventFeatureFlag for reporting. On decode failure it replaces that with a copy from the new FeatureFlag.withEvaluationResult(variation:reason:), clearing variation and setting the WRONG_TYPE reason while keeping version and tracking fields. recordFlagEvaluationEvents receives that copy instead of the raw store flag.

Tests in LDClientSpec cover 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.

…ed evaluation has the wrong type

Generated-by: termag
@keelerm84
keelerm84 requested a review from a team as a code owner November 17, 2026 16:01
@cursor cursor Bot added the risk:low label Nov 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@keelerm84
keelerm84 merged commit d76e12e into v11 Nov 17, 2026
19 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3636/wrong-type-events branch November 17, 2026 18:13
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants