Skip to content

Commit 547554a

Browse files
committed
[FLINK-26378][sdk][py] Set caller to None for ingress messages.
This commit makes sure that the caller's address would be None for messages that are coming from an ingress.
1 parent 788417d commit 547554a

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

statefun-sdk-python/statefun/request_reply_v3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def send_egress(self, message: EgressMessage):
113113
# -------------------------------------------------------------------------------------------------------------------
114114

115115
def sdk_address_from_pb(addr: Address) -> typing.Optional[SdkAddress]:
116-
if not addr:
116+
if not addr or (not addr.namespace and not addr.type and not addr.id):
117117
return None
118118
return SdkAddress(namespace=addr.namespace,
119119
name=addr.type,

statefun-sdk-python/tests/request_reply_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,16 @@ def fun(context, message):
229229
self.assertEqual(missing_state_2_spec['state_name'], 'missing_state_2')
230230
self.assertEqual(missing_state_2_spec['expiration_spec']['mode'], 'AFTER_WRITE')
231231
self.assertEqual(missing_state_2_spec['expiration_spec']['expire_after_millis'], '2000')
232+
233+
def test_caller_not_set(self):
234+
functions = StatefulFunctions()
235+
236+
@functions.bind(typename='org.foo/greeter')
237+
def fun(context: Context, message: Message):
238+
self.assertIsNone(context.caller)
239+
240+
builder = InvocationBuilder()
241+
builder.with_target("org.foo", "greeter", "0")
242+
builder.with_invocation("Hello", StringType)
243+
244+
round_trip(functions, builder)

0 commit comments

Comments
 (0)