Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus]Match the partition key with session id only when both are set #19233

Merged
4 commits merged into from
Jun 22, 2021
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
6 changes: 6 additions & 0 deletions sdk/servicebus/azure-servicebus/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 7.3.1 (Unreleased)

**Bug Fixes**

* Fixed a bug that when setting `ServiceBusMessage.partition_key`, input value should be not validated against `session_id` of None (PR #19233, thanks @bishnu-shb).

## 7.3.0 (2021-06-08)

**New Features**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def partition_key(self, value):
)
)

if value and value != self.session_id:
if value and self.session_id and value != self.session_id:
raise ValueError(
"partition_key:{} cannot be set to a different value than session_id:{}".format(
value, self.session_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Licensed under the MIT License.
# ------------------------------------

VERSION = "7.3.0"
VERSION = "7.3.1"
6 changes: 2 additions & 4 deletions sdk/servicebus/azure-servicebus/tests/test_queues.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def test_queue_by_queue_client_conn_str_receive_handler_peeklock(self, servicebu
message.content_type = 'application/text'
message.correlation_id = 'cid'
message.message_id = str(i)
with pytest.raises(ValueError):
message.partition_key = 'pk'
message.partition_key = 'pk'
message.to = 'to'
message.reply_to = 'reply_to'
sender.send_messages(message)
Expand Down Expand Up @@ -216,8 +215,7 @@ def test_queue_by_queue_client_send_multiple_messages(self, servicebus_namespace
messages = []
for i in range(10):
message = ServiceBusMessage("Handler message no. {}".format(i))
with pytest.raises(ValueError):
message.partition_key = 'pkey'
message.partition_key = 'pkey'
message.time_to_live = timedelta(seconds=60)
message.scheduled_enqueue_time_utc = utc_now() + timedelta(seconds=60)
message.partition_key = None
Expand Down
3 changes: 1 addition & 2 deletions sdk/servicebus/azure-servicebus/tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def test_session_by_session_client_conn_str_receive_handler_peeklock(self, servi
for i in range(3):
message = ServiceBusMessage("Handler message no. {}".format(i))

with pytest.raises(ValueError):
message.partition_key = 'pkey'
message.partition_key = 'pkey'

message.session_id = session_id
message.partition_key = session_id
Expand Down