quonfig 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 939842e745249a0ce6cee689801a6fe3a7cbdc56552ad88bdabaa0c36e79ef92
4
- data.tar.gz: df5b171629c4b6c556f04b80a0035d5726c76929e78d11ba5382332d0e4b2293
3
+ metadata.gz: 7fb6a1cbb69335648d8e68194ef6c177360f575248942a145b214fae2e3a0bf6
4
+ data.tar.gz: 7782d66fe639d2b690932d7d3c7ed2becb793c0a18252ddd7988424eaf29fec5
5
5
  SHA512:
6
- metadata.gz: 4c6822328fa6147d3816b404fe9543991d7095a5f663a2dc045f425113daba93f18da02e739c32dfce962858b00c190809acf4a62e56f1f049669bf813d8cdcd
7
- data.tar.gz: 04a636c09573823cf0895c3cbbdcd2d9d79f22b875a877e55587244a2077bf1ae054007b729cc64bb8a2208e806fbdb962a7c55be38f2663c015b41d2685e09d
6
+ metadata.gz: 3ff89f7539988b7a95527fcc93b8fd2b1662ed52c664c87e9855c7f9e926877d4240c04c8703e62d93f93e81c3e28ce5540c27682bfcc65e306942d3985084aa
7
+ data.tar.gz: 8ea638dc75cadf24d41bfc6030748cf03116c359e69a3f8c03a72dea26496f01fe64395502a3f6dafd437c929f07ab81121b84c66cdafeb1feff38f58ba6a875
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.2.0 - 2026-10-29
4
+
5
+ - **Changed (edge case): the `*_details` getters and `evaluate_details` report a value that cannot be parsed as `error_code: "PARSE_ERROR"` (qfg-wg1n).** A malformed ENV_VAR value (an int config whose env var is `"twelve"`, a duration env var `"PT5S garbage"`) and, on the typed getters, a malformed stored int, double or duration (`"twelve"`, `"abc"`, `"PT0.5H"`) were reported as `TYPE_MISMATCH`; they are now `PARSE_ERROR`, the code OpenFeature uses for this case, with the same `reason: "ERROR"`, nil value, variant and `flag_metadata` as before. A value of another type (`get_int_details` on a string config) is still `TYPE_MISMATCH`. The new constant is `Quonfig::EvaluationDetails::ERROR_PARSE_ERROR`. Only the error code on these failure paths changes: the plain getters, `get_or_raise` and the raised errors (`EnvVarParseError`, `TypeMismatchError`) are unchanged, and `evaluate_details` still returns a malformed stored value as stored with a success reason. Code that compared `error_code` to `TYPE_MISMATCH` to detect a malformed value should also accept `PARSE_ERROR`. quonfig-openfeature 2.3.0 already passes `PARSE_ERROR` straight through. Tests: `test/test_parse_error_details.rb`.
6
+
3
7
  ## 2.1.0 - 2026-10-29
4
8
 
5
9
  - **Added: `evaluate_details(key, context:)`, an untyped details read (qfg-177f).** It returns a `Quonfig::EvaluationDetails` whose `value` is the config's resolved value as stored, after ENV_VAR provision and decryption, with no type check or conversion: a duration comes back as its ISO 8601 text exactly as stored (`"PT90S"`, not milliseconds), a `string_list` as an Array, JSON as stored. The new `value_type` attribute names the stored type (`"duration"`, `"int"`, ...; `nil` when nothing resolved). Reason, variant, `flag_metadata`, error codes and telemetry are the same as the typed `*_details` getters, and it never raises. A malformed stored value (a duration `"30s"`) is returned as-is with a success reason; an unset or unparseable ENV_VAR is still `reason: "ERROR"`, as in the typed getters. Available on the client and on a `with_context` bound client. It matches sdk-go's `Client.EvaluateDetails` and is meant for OpenFeature providers and other callers that do their own typing. Existing getters are unchanged. Tests: `test/test_evaluate_details.rb`.
data/README.md CHANGED
@@ -480,8 +480,11 @@ default only covers a missing key). For a typed read that raises, call the
480
480
  typed getter with no `default:` under `on_no_default: :raise`.
481
481
 
482
482
  The `*_details` getters (`get_int_details(key, context:)` and so on) never
483
- raise. They return `Quonfig::EvaluationDetails`; a wrong-type or malformed
484
- value is `reason: "ERROR"` with `error_code: "TYPE_MISMATCH"`.
483
+ raise. They return `Quonfig::EvaluationDetails`; a value of another type is
484
+ `reason: "ERROR"` with `error_code: "TYPE_MISMATCH"`, and a value that cannot
485
+ be parsed as its declared type (a malformed ENV_VAR value, or a malformed
486
+ stored int, double or duration) is `reason: "ERROR"` with
487
+ `error_code: "PARSE_ERROR"`.
485
488
  `get_duration_details` carries the duration in integer milliseconds.
486
489
 
487
490
  To read a value without a type, use `evaluate_details(key, context:)`. It
@@ -282,7 +282,10 @@ module Quonfig
282
282
  # carrying the OpenFeature-aligned resolution +reason+ ("STATIC",
283
283
  # "TARGETING_MATCH", "SPLIT", "DEFAULT", or "ERROR") plus an
284
284
  # +error_code+/+error_message+ on the error path. These methods never
285
- # raise — exceptions are caught and rendered as ERROR details.
285
+ # raise — exceptions are caught and rendered as ERROR details. A value of
286
+ # another type is error_code TYPE_MISMATCH; a value that cannot be parsed
287
+ # as its declared type (a malformed ENV_VAR value, a malformed stored
288
+ # int, double or duration) is PARSE_ERROR.
286
289
 
287
290
  def get_bool_details(key, context: NO_DEFAULT_PROVIDED)
288
291
  build_details(key, :bool, context)
@@ -310,7 +313,7 @@ module Quonfig
310
313
 
311
314
  # Integer milliseconds in +value+ (qfg-2agi.27). A config whose valueType
312
315
  # is not duration is ERROR / TYPE_MISMATCH; a malformed value (stored or
313
- # ENV_VAR) is ERROR with a nil value.
316
+ # ENV_VAR) is ERROR / PARSE_ERROR with a nil value.
314
317
  def get_duration_details(key, context: NO_DEFAULT_PROVIDED)
315
318
  build_details(key, :duration, context)
316
319
  end
@@ -2230,11 +2233,11 @@ module Quonfig
2230
2233
  )
2231
2234
  rescue Quonfig::Errors::EnvVarParseError => e
2232
2235
  # An ENV_VAR value that does not parse as the config's type is
2233
- # TYPE_MISMATCH, like a malformed stored value (as in sdk-go).
2236
+ # PARSE_ERROR, like a malformed stored value (qfg-wg1n).
2234
2237
  return Quonfig::EvaluationDetails.new(
2235
2238
  value: nil,
2236
2239
  reason: Quonfig::EvaluationDetails::REASON_ERROR,
2237
- error_code: Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH,
2240
+ error_code: Quonfig::EvaluationDetails::ERROR_PARSE_ERROR,
2238
2241
  error_message: e.message,
2239
2242
  variant: build_variant(Quonfig::EvaluationDetails::REASON_ERROR, nil, nil),
2240
2243
  flag_metadata: build_flag_metadata(nil, nil, nil, nil, nil)
@@ -2258,12 +2261,12 @@ module Quonfig
2258
2261
  begin
2259
2262
  coerced = expected_type.nil? ? stored_value(result) : typed_value(key, result, expected_type)
2260
2263
  rescue Quonfig::Errors::TypeMismatchError, Quonfig::Errors::EnvVarParseError => e
2261
- # A wrong-type value and a malformed one (the getter cannot produce
2262
- # a value of its type) are both TYPE_MISMATCH, as in sdk-go.
2264
+ # A value of another type is TYPE_MISMATCH; a malformed one (a stored
2265
+ # int "twelve", a duration "30s") is PARSE_ERROR (qfg-wg1n).
2263
2266
  return Quonfig::EvaluationDetails.new(
2264
2267
  value: nil,
2265
2268
  reason: Quonfig::EvaluationDetails::REASON_ERROR,
2266
- error_code: Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH,
2269
+ error_code: details_error_code(e),
2267
2270
  error_message: e.message,
2268
2271
  variant: build_variant(Quonfig::EvaluationDetails::REASON_ERROR, nil, nil),
2269
2272
  flag_metadata: build_flag_metadata(config_id, config_type, nil, nil, nil)
@@ -2293,6 +2296,14 @@ module Quonfig
2293
2296
  )
2294
2297
  end
2295
2298
 
2299
+ def details_error_code(error)
2300
+ if error.is_a?(Quonfig::Errors::EnvVarParseError)
2301
+ Quonfig::EvaluationDetails::ERROR_PARSE_ERROR
2302
+ else
2303
+ Quonfig::EvaluationDetails::ERROR_TYPE_MISMATCH
2304
+ end
2305
+ end
2306
+
2296
2307
  # +result+'s resolved value in stored form (after ENV_VAR provision and
2297
2308
  # decryption) with no coercion or parse validation: a duration is its
2298
2309
  # ISO 8601 text as stored. Hashes and Arrays are copied so a caller
@@ -15,7 +15,10 @@ module Quonfig
15
15
  #
16
16
  # +error_code+ (only when reason == "ERROR") is one of:
17
17
  # "FLAG_NOT_FOUND" — the key was unknown to the store
18
- # "TYPE_MISMATCH" — the resolved value didn't satisfy the requested type
18
+ # "TYPE_MISMATCH" — the resolved value is of another type than the getter's
19
+ # "PARSE_ERROR" — the value cannot be parsed as its declared type: a
20
+ # malformed ENV_VAR value, or a malformed stored int,
21
+ # double or duration (qfg-wg1n)
19
22
  # "PROVIDER_NOT_READY" — the client has no config yet (init continued
20
23
  # on code defaults, or a caught init failure)
21
24
  # "GENERAL" — any other failure
@@ -32,6 +35,7 @@ module Quonfig
32
35
 
33
36
  ERROR_FLAG_NOT_FOUND = 'FLAG_NOT_FOUND'
34
37
  ERROR_TYPE_MISMATCH = 'TYPE_MISMATCH'
38
+ ERROR_PARSE_ERROR = 'PARSE_ERROR'
35
39
  ERROR_GENERAL = 'GENERAL'
36
40
  ERROR_PROVIDER_NOT_READY = 'PROVIDER_NOT_READY'
37
41
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quonfig
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quonfig
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dwyer