Skip to content

Commit 66dcce7

Browse files
committed
Update resolver logic
1 parent 4310d8c commit 66dcce7

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

src/asyncapi_python/contrib/wire/amqp/producer.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,18 @@ async def send_batch(
120120
address_override if address_override is not None else self._routing_key
121121
)
122122

123-
# Note: empty string is valid for default exchange routing
124-
# All valid routing configurations should result in a non-None string at this point
123+
# Validate we have a destination
124+
# Fail ONLY if both are truly missing:
125+
# - address_override is None (not provided by caller)
126+
# - AND self._routing_key is "" (no static config was derived from channel/bindings/operation)
127+
# Note: empty string IS valid when explicitly configured (fanout exchanges, default exchange)
128+
if address_override is None and not self._routing_key:
129+
raise ValueError(
130+
f"Cannot send: no routing destination available. "
131+
f"RPC replies require reply_to from the request, or the channel must "
132+
f"have address/bindings/operation-name to derive destination. "
133+
f"(address_override={address_override}, routing_key={self._routing_key!r})"
134+
)
125135

126136
for message in messages:
127137
amqp_message = AmqpMessage(

0 commit comments

Comments
 (0)