From 4f17eed83ac1f0869f4f3966eeb042ad14c782bc Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Mon, 9 Nov 2026 16:22:09 +0000 Subject: [PATCH 1/2] feat: Add overrideAffected to the flag metadata Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> --- README.md | 1 + .../impl/details_converter.rb | 7 ++++-- spec/impl/details_converter_spec.rb | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index debd045..299d147 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,7 @@ Evaluations include flag metadata for the LaunchDarkly specific parts of the eva |---------------------|---------|--------------------------------------------------------------------| | `variationIndex` | integer | The index of the returned variation. Absent for default values. | | `inExperiment` | boolean | Present, and `true`, when the evaluation was part of an experiment. | +| `overrideAffected` | boolean | Present, and `true`, when a flag override affected the evaluation. Requires a LaunchDarkly Ruby SDK version with flag overrides. | | `ruleIndex` | integer | The index of the rule that matched. | | `ruleId` | string | The identifier of the rule that matched. | | `prerequisiteKey` | string | The key of the prerequisite flag that failed. | diff --git a/lib/ldclient-openfeature/impl/details_converter.rb b/lib/ldclient-openfeature/impl/details_converter.rb index 353020b..1c507df 100644 --- a/lib/ldclient-openfeature/impl/details_converter.rb +++ b/lib/ldclient-openfeature/impl/details_converter.rb @@ -9,13 +9,14 @@ module Impl class ResolutionDetailsConverter VARIATION_INDEX_KEY = 'variationIndex' IN_EXPERIMENT_KEY = 'inExperiment' + OVERRIDE_AFFECTED_KEY = 'overrideAffected' RULE_INDEX_KEY = 'ruleIndex' RULE_ID_KEY = 'ruleId' PREREQUISITE_KEY_KEY = 'prerequisiteKey' BIG_SEGMENTS_STATUS_KEY = 'bigSegmentsStatus' - private_constant :VARIATION_INDEX_KEY, :IN_EXPERIMENT_KEY, :RULE_INDEX_KEY, :RULE_ID_KEY, - :PREREQUISITE_KEY_KEY, :BIG_SEGMENTS_STATUS_KEY + private_constant :VARIATION_INDEX_KEY, :IN_EXPERIMENT_KEY, :OVERRIDE_AFFECTED_KEY, :RULE_INDEX_KEY, + :RULE_ID_KEY, :PREREQUISITE_KEY_KEY, :BIG_SEGMENTS_STATUS_KEY # # @param detail [LaunchDarkly::EvaluationDetail] @@ -61,6 +62,8 @@ def to_resolution_details(detail) metadata[VARIATION_INDEX_KEY] = variation_index unless variation_index.nil? metadata[IN_EXPERIMENT_KEY] = true if reason.in_experiment + # Only LaunchDarkly Ruby SDK versions with flag overrides define override_affected. + metadata[OVERRIDE_AFFECTED_KEY] = true if reason.respond_to?(:override_affected) && reason.override_affected metadata[RULE_INDEX_KEY] = reason.rule_index unless reason.rule_index.nil? metadata[RULE_ID_KEY] = reason.rule_id unless reason.rule_id.nil? metadata[PREREQUISITE_KEY_KEY] = reason.prerequisite_key unless reason.prerequisite_key.nil? diff --git a/spec/impl/details_converter_spec.rb b/spec/impl/details_converter_spec.rb index c4914f8..cdd5930 100644 --- a/spec/impl/details_converter_spec.rb +++ b/spec/impl/details_converter_spec.rb @@ -63,6 +63,31 @@ expect(resolution_details.flag_metadata).not_to have_key('inExperiment') end + it "includes override affected in the flag metadata for override-affected evaluations" do + reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false) + allow(reason).to receive(:override_affected).and_return(true) + detail = LaunchDarkly::EvaluationDetail.new(true, 1, reason) + resolution_details = details_converter.to_resolution_details(detail) + + expect(resolution_details.flag_metadata).to include('overrideAffected' => true) + end + + it "omits override affected from the flag metadata for evaluations not affected by an override" do + reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false) + allow(reason).to receive(:override_affected).and_return(false) + detail = LaunchDarkly::EvaluationDetail.new(true, 1, reason) + resolution_details = details_converter.to_resolution_details(detail) + + expect(resolution_details.flag_metadata).not_to have_key('overrideAffected') + end + + it "omits override affected from the flag metadata when the LaunchDarkly SDK does not support overrides" do + detail = LaunchDarkly::EvaluationDetail.new(true, 1, LaunchDarkly::EvaluationReason::fallthrough(false)) + resolution_details = details_converter.to_resolution_details(detail) + + expect(resolution_details.flag_metadata).not_to have_key('overrideAffected') + end + it "includes the rule in the flag metadata for rule matches" do detail = LaunchDarkly::EvaluationDetail.new(true, 1, LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false)) resolution_details = details_converter.to_resolution_details(detail) From 461bd56368b9c745b006be37351944f0580cb148 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:43:37 +0000 Subject: [PATCH 2/2] feat: add overrideAffected to flag metadata Co-Authored-By: Ryan Lamb <4955475+kinyoklion@users.noreply.github.com> --- README.md | 4 ++-- launchdarkly-openfeature-server-sdk.gemspec | 2 +- .../impl/details_converter.rb | 3 +-- spec/impl/details_converter_spec.rb | 16 +++++++++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 299d147..71057dd 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ This matrix mirrors the [feature matrix of the OpenFeature SDK for Ruby](https:/ | ✅ | Tracking | `track` sends a LaunchDarkly custom event for the evaluation context, with the tracking event value and remaining details attached. | | ✅ | Transaction Context Propagation | Provided by the OpenFeature SDK, which merges the transaction context into the evaluation context before the provider is called; no provider support is required. | | ✅ | Extending | This provider is itself an extension of the OpenFeature SDK. The underlying LaunchDarkly client is available through `provider.client` for functionality with no OpenFeature equivalent. | -| ✅ | Flag metadata | LaunchDarkly evaluation reason details are returned as OpenFeature flag metadata. See [Flag Metadata](#flag-metadata). | +| ✅ | Flag metadata | LaunchDarkly evaluation reason details, including `overrideAffected`, are returned as OpenFeature flag metadata. See [Flag Metadata](#flag-metadata). | Supported: ✅ | Partially supported: ⚠️ | Not supported: ❌ @@ -176,7 +176,7 @@ Evaluations include flag metadata for the LaunchDarkly specific parts of the eva |---------------------|---------|--------------------------------------------------------------------| | `variationIndex` | integer | The index of the returned variation. Absent for default values. | | `inExperiment` | boolean | Present, and `true`, when the evaluation was part of an experiment. | -| `overrideAffected` | boolean | Present, and `true`, when a flag override affected the evaluation. Requires a LaunchDarkly Ruby SDK version with flag overrides. | +| `overrideAffected` | boolean | Present, and `true`, when a flag override affected the evaluation. | | `ruleIndex` | integer | The index of the rule that matched. | | `ruleId` | string | The identifier of the rule that matched. | | `prerequisiteKey` | string | The key of the prerequisite flag that failed. | diff --git a/launchdarkly-openfeature-server-sdk.gemspec b/launchdarkly-openfeature-server-sdk.gemspec index 824f8ec..c812dc7 100644 --- a/launchdarkly-openfeature-server-sdk.gemspec +++ b/launchdarkly-openfeature-server-sdk.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_runtime_dependency "launchdarkly-server-sdk", "~> 8.19" + spec.add_runtime_dependency "launchdarkly-server-sdk", "~> 8.20" spec.add_runtime_dependency "openfeature-sdk", ">= 0.6.1", "< 0.9" # For more information and examples about making a new gem, check out our diff --git a/lib/ldclient-openfeature/impl/details_converter.rb b/lib/ldclient-openfeature/impl/details_converter.rb index 1c507df..79802b8 100644 --- a/lib/ldclient-openfeature/impl/details_converter.rb +++ b/lib/ldclient-openfeature/impl/details_converter.rb @@ -62,8 +62,7 @@ def to_resolution_details(detail) metadata[VARIATION_INDEX_KEY] = variation_index unless variation_index.nil? metadata[IN_EXPERIMENT_KEY] = true if reason.in_experiment - # Only LaunchDarkly Ruby SDK versions with flag overrides define override_affected. - metadata[OVERRIDE_AFFECTED_KEY] = true if reason.respond_to?(:override_affected) && reason.override_affected + metadata[OVERRIDE_AFFECTED_KEY] = true if reason.override_affected metadata[RULE_INDEX_KEY] = reason.rule_index unless reason.rule_index.nil? metadata[RULE_ID_KEY] = reason.rule_id unless reason.rule_id.nil? metadata[PREREQUISITE_KEY_KEY] = reason.prerequisite_key unless reason.prerequisite_key.nil? diff --git a/spec/impl/details_converter_spec.rb b/spec/impl/details_converter_spec.rb index cdd5930..2b1c170 100644 --- a/spec/impl/details_converter_spec.rb +++ b/spec/impl/details_converter_spec.rb @@ -64,8 +64,7 @@ end it "includes override affected in the flag metadata for override-affected evaluations" do - reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false) - allow(reason).to receive(:override_affected).and_return(true) + reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false).with_override_affected(true) detail = LaunchDarkly::EvaluationDetail.new(true, 1, reason) resolution_details = details_converter.to_resolution_details(detail) @@ -73,21 +72,28 @@ end it "omits override affected from the flag metadata for evaluations not affected by an override" do - reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false) - allow(reason).to receive(:override_affected).and_return(false) + reason = LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false).with_override_affected(false) detail = LaunchDarkly::EvaluationDetail.new(true, 1, reason) resolution_details = details_converter.to_resolution_details(detail) expect(resolution_details.flag_metadata).not_to have_key('overrideAffected') end - it "omits override affected from the flag metadata when the LaunchDarkly SDK does not support overrides" do + it "omits override affected from the flag metadata when the reason does not mark it" do detail = LaunchDarkly::EvaluationDetail.new(true, 1, LaunchDarkly::EvaluationReason::fallthrough(false)) resolution_details = details_converter.to_resolution_details(detail) expect(resolution_details.flag_metadata).not_to have_key('overrideAffected') end + it "includes override affected in the flag metadata for error evaluations affected by an override" do + reason = LaunchDarkly::EvaluationReason::error(LaunchDarkly::EvaluationReason::ERROR_FLAG_NOT_FOUND).with_override_affected(true) + detail = LaunchDarkly::EvaluationDetail.new(true, nil, reason) + resolution_details = details_converter.to_resolution_details(detail) + + expect(resolution_details.flag_metadata).to eq({'overrideAffected' => true}) + end + it "includes the rule in the flag metadata for rule matches" do detail = LaunchDarkly::EvaluationDetail.new(true, 1, LaunchDarkly::EvaluationReason::rule_match(2, 'the-rule-id', false)) resolution_details = details_converter.to_resolution_details(detail)