anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: azure/azure-sdk-for-python
Issue: `show_in_gui` updates do not take effect

Similar to #793 but different...

I have now put a debug line on the `_perform_put` in the service management client.

I can see that the XML is what I'd expect:

``` shell
<OSImage xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windowsazure"><Label>Red Hat Enterprise Linux 6.8</Label><Eula>http://www.redhat.com/licenses/cloud_CSSA/Red_Hat_Cloud_Software_Subscription_Agreement_for_Microsoft_Azure.pdf</Eula><Description>Red Hat Enterprise Linux is the world\\'s leading enterprise Linux platform built to meet the needs of today\\'s modern enterprise. Red Hat Enterprise Linux is the preferred choice for enterprise Linux workloads on Microsoft Azure. Red Hat Enterprise Linux is an open, reliable, and secure platform designed for customers who want deployment flexibility for their business-critical workloads - from the data center to the Azure cloud - backed by tightly integrated, enterprise-grade support from Red Hat and Microsoft</Description><ImageFamily>Red Hat Enterprise Linux 6.8</ImageFamily><PublishedDate>2016-09-14T07:00:00Z</PublishedDate><ShowInGui>false</ShowInGui><IconUri></IconUri><PrivacyUri>http://www.redhat.com/licenses/cloud_CSSA/Red_Hat_Privacy_Statement_for_Microsoft_Azure.pdf</PrivacyUri><RecommendedVMSize></RecommendedVMSize><SmallIconUri></SmallIconUri><Language></Language></OSImage>
```

But the ShowInGui value for the image isn't actually updated. Is it possible there's an ordering problem here for the values inside `<OSImage>`?


Changed files:
azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py

diff --git a/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py b/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
index e732d94dfd..9811e63293 100644
--- a/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
+++ b/azure-servicemanagement-legacy/azure/servicemanagement/_serialization.py
@@ -1200,8 +1200,8 @@ class _XmlSerializer(object):
                 ('Eula', image.eula),
                 ('Description', image.description),
                 ('ImageFamily', image.image_family),
-                ('PublishedDate', image.published_date),
                 ('ShowInGui', image.show_in_gui, _lower),
+                ('PublishedDate', image.published_date),
                 ('IconUri', image.icon_uri),
                 ('PrivacyUri', image.privacy_uri),
                 ('RecommendedVMSize', image.recommended_vm_size),
Repository: azure/azure-sdk-for-python
Issue: Service Bus: reading brokerproperties in _create_message throws ValueError

Line 258 of azure/servicebus/**init**.py is:

  broker_properties = ast.literal_eval(value)

This line often throws ValueError because the 'value' it's trying to eval is not value python (it's valid json).

Here's an example of a value coming from the broker properties from an Azure Service Bus message:

{"DeliveryCount":4,"EnqueuedTimeUtc":"Tue, 15 Apr 2014 20:52:34 GMT","ForcePersistence":false,"LockToken":"9b946475-8e67-4f60-8499-8a4c5cbb7bfc","LockedUntilUtc":"Mon, 18 Aug 2014 08:17:05 GMT","MessageId":"7014fa25dc8c418bb90312de1251d8a5","SequenceNumber":562975,"State":"Active","TimeToLive":604800}

Notice that ForcePersistence is "false", not "False".  This causes ast.literal_eval to fail.

This is a pretty serious bug as valid messages appear to be unreadable by the python azure sdk.  One suggested fix would be to replace line 258 with

  broker_properties = json.loads(value)

That seems to work fine.


Changed files:
tests/test_servicebusservice.py, azure/servicebus/__init__.py

diff --git a/azure/servicebus/__init__.py b/azure/servicebus/__init__.py
index 9094b26cb7..eeeb1de146 100644
--- a/azure/servicebus/__init__.py
+++ b/azure/servicebus/__init__.py
@@ -13,6 +13,7 @@
 # limitations under the License.
 #--------------------------------------------------------------------------
 import ast
+import json
 import sys
 
 from datetime import datetime
@@ -255,7 +256,7 @@ def _create_message(response, service_instance):
     # gets all information from respheaders.
     for name, value in response.headers:
         if name.lower() == 'brokerproperties':
-            broker_properties = ast.literal_eval(value)
+            broker_properties = json.loads(value)
         elif name.lower() == 'content-type':
             message_type = value
         elif name.lower() == 'location':
diff --git a/tests/test_servicebusservice.py b/tests/test_servicebusservice.py
index 9ae3c79682..d72448b7be 100644
--- a/tests/test_servicebusservice.py
+++ b/tests/test_servicebusservice.py
@@ -331,6 +331,22 @@ class ServiceBusTest(AzureTestCase):
         self.assertIsNotNone(received_msg)
         self.assertEqual(sent_msg.body, received_msg.body)
 
+    def test_receive_queue_message_with_broker_properties(self):
+        # Assert
+        sent_msg = Message(b'receive message')
+        sent_msg.broker_properties = \\
+            '{"ForcePersistence": false, "Label": "My label" }'
+        self._create_queue_and_send_msg(self.queue_name, sent_msg)
+
+        # Act
+        received_msg = self.sbs.receive_queue_message(self.queue_name, False)
+
+        # Assert
+        self.assertIsNotNone(received_msg)
+        self.assertEqual(sent_msg.body, received_msg.body)
+        self.assertEqual("My label", received_msg.broker_properties['Label'])
+        self.assertEqual(False, received_msg.broker_properties['ForcePersistence'])
+
     def test_receive_queue_message_read_delete_mode_throws_on_delete(self):
         # Assert
         sent_msg = Message(b'receive message')