Skip to content

Commit e7d1d34

Browse files
feat!: DISABLED is a successful evaluation (still defaults) (#395)
* feat(flagd-core): add disabled flag evaluation e2e BDD scenarios Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> * chore: bump flagd-testbed submodule to v3.8.0 Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * feat(flagd): RPC resolver substitutes caller default on reason=DISABLED Mirrors the existing reason=DEFAULT substitution: when the server returns an empty variant alongside DISABLED, surface the caller's code default value rather than the zero proto value. Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * fix(flagd): RPC Object resolver tolerates missing value field MessageToDict drops the value field entirely for DISABLED responses (no value is sent). Fall back to the caller's default_value via .get() instead of raising KeyError; the substitution branch then surfaces the default with reason=DISABLED. Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * style(flagd): apply ruff format to DISABLED guard Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * chore(flagd-core): drop redundant disabled.feature and test_disabled.py v3.8.0 of the test-harness submodule already bundles disabled.feature in evaluator/gherkin/ and the disabled-* flags in evaluator/flags/testkit-flags.json. The hatch build hook auto-copies both into the testkit, so test_evaluator.py picks the disabled scenarios up via get_features_path() without any local files. Signed-off-by: Todd Baert <todd.baert@dynatrace.com> * Apply suggestion from @toddbaert Signed-off-by: Todd Baert <todd.baert@dynatrace.com> --------- Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com> Signed-off-by: Todd Baert <todd.baert@dynatrace.com> Co-authored-by: Todd Baert <todd.baert@dynatrace.com>
1 parent e1c3c6a commit e7d1d34

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

  • providers/openfeature-provider-flagd

providers/openfeature-provider-flagd/src/openfeature/contrib/provider/flagd/resolvers/grpc.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -409,9 +409,10 @@ def _resolve( # noqa: PLR0915 C901
409409
flag_key=flag_key, context=context
410410
)
411411
response = self.stub.ResolveObject(request, **call_args)
412-
value = MessageToDict(response, preserving_proto_field_name=True)[
413-
"value"
414-
]
412+
# DISABLED responses omit the value field entirely; fall back to default_value
413+
value = MessageToDict(response, preserving_proto_field_name=True).get(
414+
"value", default_value
415+
)
415416
elif flag_type == FlagType.FLOAT:
416417
request = evaluation_pb2.ResolveFloatRequest(
417418
flag_key=flag_key, context=context
@@ -443,8 +444,12 @@ def _resolve( # noqa: PLR0915 C901
443444
raise GeneralError(message) from e
444445

445446
# When no default variant is configured, the server returns an empty/zero proto
446-
# value with reason=DEFAULT. In that case, return the caller's code default value.
447-
if response.reason == Reason.DEFAULT and not response.variant:
447+
# value with reason=DEFAULT. For DISABLED flags the server omits the variant too.
448+
# In both cases, return the caller's code default value.
449+
if (
450+
response.reason in (Reason.DEFAULT, Reason.DISABLED)
451+
and not response.variant
452+
):
448453
value = default_value
449454

450455
# Got a valid flag and valid type. Return it.

0 commit comments

Comments
 (0)