Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,10 @@ def _resolve( # noqa: PLR0915 C901
flag_key=flag_key, context=context
)
response = self.stub.ResolveObject(request, **call_args)
value = MessageToDict(response, preserving_proto_field_name=True)[
"value"
]
# DISABLED responses omit the value field entirely; fall back to default_value
value = MessageToDict(response, preserving_proto_field_name=True).get(
"value", default_value
)
elif flag_type == FlagType.FLOAT:
request = evaluation_pb2.ResolveFloatRequest(
flag_key=flag_key, context=context
Expand Down Expand Up @@ -443,8 +444,12 @@ def _resolve( # noqa: PLR0915 C901
raise GeneralError(message) from e

# When no default variant is configured, the server returns an empty/zero proto
# value with reason=DEFAULT. In that case, return the caller's code default value.
if response.reason == Reason.DEFAULT and not response.variant:
# value with reason=DEFAULT. For DISABLED flags the server omits the variant too.
# In both cases, return the caller's code default value.
if (
response.reason in (Reason.DEFAULT, Reason.DISABLED)
and not response.variant
):
value = default_value

# Got a valid flag and valid type. Return it.
Expand Down
Loading