launchdarkly-server-sdk 8.7.0 → 8.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5af0bbef2faa957948f0a7f50e15fcabe977389a33985907183d58325e1c6b3d
4
- data.tar.gz: 4ecb07d71897441c2d02cc1972a75b63f07615b6fa1266330f7403c5e36c01c2
3
+ metadata.gz: ad194623a6f35a835f5b80ce5068146bbb68ae0b7ee170824ffef66be5e5b152
4
+ data.tar.gz: 999fb27820fd61a422f14c62cf59a9a6f894fc34ac24be794a4144a13ad9dd35
5
5
  SHA512:
6
- metadata.gz: 22409520414843c8249e2fa303686289c3701d7802fb558fe87870d4d5293381fabbf4f0634f6a14784e77eb328a5601929e096555bdc14f66ee4826a6f36316
7
- data.tar.gz: 36f9746807944960f161f83f4a37258d0d6ce1035018dc4d49c2e9b2a1d09fa96e83f35e6a1a0afeb30ee902bf4713e74ef06d32068611458d384a35561775e9
6
+ metadata.gz: be9ca147365077934dbeb17eb70df914679fb2dbf2360d971f7f2dd2fc1e72e2dfbf72be371ef5757bfaf9809cd7057f749936fcb89635d2a7ff530f8f590945
7
+ data.tar.gz: 2a8e19486d6897dd4eb5ed5bac30374087cb79817b1970218d7e360595da72a727360d50cddebdfcf3db6e340cffdfbbd8c042c5daece294b9233755a9a0d8cc
@@ -77,7 +77,7 @@ module LaunchDarkly
77
77
  @socket_factory = opts[:socket_factory]
78
78
  @big_segments = opts[:big_segments] || BigSegmentsConfig.new(store: nil)
79
79
  @application = LaunchDarkly::Impl::Util.validate_application_info(opts[:application] || {}, @logger)
80
- @payload_filter_key = opts[:payload_filter_key]
80
+ @payload_filter_key = LaunchDarkly::Impl::Util.validate_payload_filter_key(opts[:payload_filter_key] , @logger)
81
81
  @hooks = (opts[:hooks] || []).keep_if { |hook| hook.is_a? Interfaces::Hooks::Hook }
82
82
  @omit_anonymous_contexts = opts.has_key?(:omit_anonymous_contexts) && opts[:omit_anonymous_contexts]
83
83
  @data_source_update_sink = nil
@@ -38,6 +38,7 @@ module LaunchDarkly
38
38
  meta[:version] = flag_state[:version]
39
39
  end
40
40
 
41
+ meta[:prerequisites] = flag_state[:prerequisites] unless flag_state[:prerequisites].nil? || flag_state[:prerequisites].empty?
41
42
  meta[:variation] = flag_state[:variation] unless flag_state[:variation].nil?
42
43
  meta[:trackEvents] = true if flag_state[:trackEvents]
43
44
  meta[:trackReason] = true if flag_state[:trackReason]
@@ -32,8 +32,16 @@ module LaunchDarkly
32
32
  def initialize(original_flag)
33
33
  @prereq_stack = EvaluatorStack.new(original_flag.key)
34
34
  @segment_stack = EvaluatorStack.new(nil)
35
+ @prerequisites = []
36
+ @depth = 0
35
37
  end
36
38
 
39
+ def record_evaluated_prereq_key(key)
40
+ @prerequisites.push(key) if @depth.zero?
41
+ end
42
+
43
+ attr_accessor :depth
44
+ attr_reader :prerequisites
37
45
  attr_reader :prereq_stack
38
46
  attr_reader :segment_stack
39
47
  end
@@ -135,7 +143,8 @@ module LaunchDarkly
135
143
  #
136
144
  # @param flag [LaunchDarkly::Impl::Model::FeatureFlag] the flag
137
145
  # @param context [LaunchDarkly::LDContext] the evaluation context
138
- # @return [EvalResult] the evaluation result
146
+ # @return [Array<EvalResult, EvaluatorState>] the evaluation result and a state object that may be used for
147
+ # inspecting the evaluation process
139
148
  def evaluate(flag, context)
140
149
  state = EvaluatorState.new(flag)
141
150
 
@@ -145,11 +154,11 @@ module LaunchDarkly
145
154
  rescue EvaluationException => exn
146
155
  LaunchDarkly::Util.log_exception(@logger, "Unexpected error when evaluating flag #{flag.key}", exn)
147
156
  result.detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(exn.error_kind))
148
- return result
157
+ return result, state
149
158
  rescue => exn
150
159
  LaunchDarkly::Util.log_exception(@logger, "Unexpected error when evaluating flag #{flag.key}", exn)
151
160
  result.detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(EvaluationReason::ERROR_EXCEPTION))
152
- return result
161
+ return result, state
153
162
  end
154
163
 
155
164
  unless result.big_segments_status.nil?
@@ -159,7 +168,7 @@ module LaunchDarkly
159
168
  detail.reason.with_big_segments_status(result.big_segments_status))
160
169
  end
161
170
  result.detail = detail
162
- result
171
+ [result, state]
163
172
  end
164
173
 
165
174
  # @param segment [LaunchDarkly::Impl::Model::Segment]
@@ -223,13 +232,16 @@ module LaunchDarkly
223
232
  )
224
233
  end
225
234
 
235
+ state.record_evaluated_prereq_key(prereq_key)
226
236
  prereq_flag = @get_flag.call(prereq_key)
227
237
 
228
238
  if prereq_flag.nil?
229
239
  @logger.error { "[LDClient] Could not retrieve prerequisite flag \"#{prereq_key}\" when evaluating \"#{flag.key}\"" }
230
240
  prereq_ok = false
231
241
  else
242
+ state.depth += 1
232
243
  prereq_res = eval_internal(prereq_flag, context, eval_result, state)
244
+ state.depth -= 1
233
245
  # Note that if the prerequisite flag is off, we don't consider it a match no matter what its
234
246
  # off variation was. But we still need to evaluate it in order to generate an event.
235
247
  if !prereq_flag.on || prereq_res.variation_index != prerequisite.variation
@@ -75,6 +75,21 @@ module LaunchDarkly
75
75
  version: validate_application_value(app[:version], :version, logger),
76
76
  }
77
77
  end
78
+
79
+ #
80
+ # @param value [String, nil]
81
+ # @param logger [Logger]
82
+ # @return [String, nil]
83
+ #
84
+ def self.validate_payload_filter_key(value, logger)
85
+ return nil if value.nil?
86
+ return value if value.is_a?(String) && /^[a-zA-Z0-9][._\-a-zA-Z0-9]*$/.match?(value)
87
+
88
+ logger.warn {
89
+ "Invalid payload filter configured, full environment will be fetched. Ensure the filter key is not empty and was copied correctly from LaunchDarkly settings."
90
+ }
91
+ nil
92
+ end
78
93
  end
79
94
  end
80
95
  end
@@ -546,7 +546,8 @@ module LaunchDarkly
546
546
  next
547
547
  end
548
548
  begin
549
- detail = @evaluator.evaluate(f, context).detail
549
+ (eval_result, eval_state) = @evaluator.evaluate(f, context)
550
+ detail = eval_result.detail
550
551
  rescue => exn
551
552
  detail = EvaluationDetail.new(nil, nil, EvaluationReason::error(EvaluationReason::ERROR_EXCEPTION))
552
553
  Util.log_exception(@config.logger, "Error evaluating flag \"#{k}\" in all_flags_state", exn)
@@ -558,6 +559,7 @@ module LaunchDarkly
558
559
  value: detail.value,
559
560
  variation: detail.variation_index,
560
561
  reason: detail.reason,
562
+ prerequisites: eval_state.prerequisites,
561
563
  version: f[:version],
562
564
  trackEvents: f[:trackEvents] || requires_experiment_data,
563
565
  trackReason: requires_experiment_data,
@@ -705,7 +707,7 @@ module LaunchDarkly
705
707
  end
706
708
 
707
709
  begin
708
- res = @evaluator.evaluate(feature, context)
710
+ (res, _) = @evaluator.evaluate(feature, context)
709
711
  unless res.prereq_evals.nil?
710
712
  res.prereq_evals.each do |prereq_eval|
711
713
  record_prereq_flag_eval(prereq_eval.prereq_flag, prereq_eval.prereq_of_flag, context, prereq_eval.detail, with_reasons)
@@ -77,11 +77,6 @@ module LaunchDarkly
77
77
  def self.add_payload_filter_key(uri, config)
78
78
  return uri if config.payload_filter_key.nil?
79
79
 
80
- unless config.payload_filter_key.is_a?(String) && !config.payload_filter_key.empty?
81
- config.logger.warn { "[LDClient] Filter key must be a non-empty string. No filtering will be applied." }
82
- return uri
83
- end
84
-
85
80
  begin
86
81
  parsed = URI.parse(uri)
87
82
  new_query_params = URI.decode_www_form(String(parsed.query)) << ["filter", config.payload_filter_key]
@@ -1,3 +1,3 @@
1
1
  module LaunchDarkly
2
- VERSION = "8.7.0" # x-release-please-version
2
+ VERSION = "8.8.0" # x-release-please-version
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: launchdarkly-server-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.7.0
4
+ version: 8.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - LaunchDarkly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-25 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-dynamodb
@@ -24,6 +24,26 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.57'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rexml
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.3.7
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.3'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 3.3.7
27
47
  - !ruby/object:Gem::Dependency
28
48
  name: bundler
29
49
  requirement: !ruby/object:Gem::Requirement
@@ -390,7 +410,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
390
410
  - !ruby/object:Gem::Version
391
411
  version: '0'
392
412
  requirements: []
393
- rubygems_version: 3.5.11
413
+ rubygems_version: 3.5.16
394
414
  signing_key:
395
415
  specification_version: 4
396
416
  summary: LaunchDarkly SDK for Ruby