Skip to content

Commit 1186b3c

Browse files
committed
Only set condition message when non-empty
When message is empty, omitting the field from the protobuf message is cleaner than explicitly setting it to an empty string. Protobuf includes explicitly-set zero values in serialization, so setting message="" causes it to appear in MessageToDict output and gRPC responses even when there is nothing to say. Signed-off-by: Nic Cope <nicc@rk0n.org>
1 parent fb39682 commit 1186b3c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

crossplane/function/response.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ def set_conditions(
109109
on resource readiness.
110110
"""
111111
for condition in conditions:
112-
rsp.conditions.append(
113-
fnv1.Condition(
114-
type=condition.typ,
115-
status=_STATUS_MAP.get(condition.status, fnv1.STATUS_CONDITION_UNKNOWN),
116-
reason=condition.reason or "",
117-
message=condition.message or "",
118-
)
112+
c = fnv1.Condition(
113+
type=condition.typ,
114+
status=_STATUS_MAP.get(condition.status, fnv1.STATUS_CONDITION_UNKNOWN),
115+
reason=condition.reason or "",
119116
)
117+
if condition.message:
118+
c.message = condition.message
119+
rsp.conditions.append(c)
120120

121121

122122
def set_output(rsp: fnv1.RunFunctionResponse, output: dict | structpb.Struct) -> None:

0 commit comments

Comments
 (0)