From e55fcdb62b3fd7617356ddb76643a811915baa54 Mon Sep 17 00:00:00 2001 From: mdrichardson Date: Tue, 10 Dec 2019 11:43:48 -0800 Subject: [PATCH 1/5] typo blob -> memory --- libraries/botbuilder-core/botbuilder/core/memory_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/botbuilder-core/botbuilder/core/memory_storage.py b/libraries/botbuilder-core/botbuilder/core/memory_storage.py index b85b3d368..f4c72004e 100644 --- a/libraries/botbuilder-core/botbuilder/core/memory_storage.py +++ b/libraries/botbuilder-core/botbuilder/core/memory_storage.py @@ -62,7 +62,7 @@ async def write(self, changes: Dict[str, StoreItem]): else new_value.get("e_tag", None) ) if new_value_etag == "": - raise Exception("blob_storage.write(): etag missing") + raise Exception("memory_storage.write(): etag missing") if ( old_state_etag is not None and new_value_etag is not None From 3df91af7ddd43e2ecfd9579686c0c190750cab05 Mon Sep 17 00:00:00 2001 From: mdrichardson Date: Tue, 10 Dec 2019 11:50:51 -0800 Subject: [PATCH 2/5] fixed hasattr in MemoryStorage --- .../botbuilder/core/memory_storage.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libraries/botbuilder-core/botbuilder/core/memory_storage.py b/libraries/botbuilder-core/botbuilder/core/memory_storage.py index f4c72004e..d60ecfde5 100644 --- a/libraries/botbuilder-core/botbuilder/core/memory_storage.py +++ b/libraries/botbuilder-core/botbuilder/core/memory_storage.py @@ -48,19 +48,19 @@ async def write(self, changes: Dict[str, StoreItem]): # If it exists then we want to cache its original value from memory if key in self.memory: old_state = self.memory[key] - if not isinstance(old_state, StoreItem): + if isinstance(old_state, dict): old_state_etag = old_state.get("e_tag", None) - elif old_state.e_tag: + elif hasattr(old_state, "e_tag"): old_state_etag = old_state.e_tag new_state = new_value # Set ETag if applicable - new_value_etag = ( - new_value.e_tag - if hasattr(new_value, "e_tag") - else new_value.get("e_tag", None) - ) + new_value_etag = None + if isinstance(new_value, dict): + new_value_etag = new_value.get("e_tag", None) + elif hasattr(new_value, "e_tag"): + new_value_etag = new_value.e_tag if new_value_etag == "": raise Exception("memory_storage.write(): etag missing") if ( From cb5f13a4235ac37192392ef45f00fb042e074ad5 Mon Sep 17 00:00:00 2001 From: mdrichardson Date: Tue, 10 Dec 2019 11:53:22 -0800 Subject: [PATCH 3/5] fixed hasattr in BlobStorage --- libraries/botbuilder-azure/botbuilder/azure/blob_storage.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/botbuilder-azure/botbuilder/azure/blob_storage.py b/libraries/botbuilder-azure/botbuilder/azure/blob_storage.py index fada3fe53..b69217680 100644 --- a/libraries/botbuilder-azure/botbuilder/azure/blob_storage.py +++ b/libraries/botbuilder-azure/botbuilder/azure/blob_storage.py @@ -73,7 +73,11 @@ async def write(self, changes: Dict[str, object]): ) for (name, item) in changes.items(): - e_tag = item.e_tag if hasattr(item, "e_tag") else item.get("e_tag", None) + e_tag = None + if isinstance(item, dict): + e_tag = item.get("e_tag", None) + elif hasattr(item, "e_tag"): + e_tag = item.e_tag e_tag = None if e_tag == "*" else e_tag if e_tag == "": raise Exception("blob_storage.write(): etag missing") From 4482a4b72f6dc21e99c969e3e9a113126788ba96 Mon Sep 17 00:00:00 2001 From: mdrichardson Date: Tue, 10 Dec 2019 11:55:07 -0800 Subject: [PATCH 4/5] fixed hasattr in CosmosDbPartitionedStorage --- .../botbuilder/azure/cosmosdb_partitioned_storage.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_partitioned_storage.py b/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_partitioned_storage.py index e5c1393ac..93657bbed 100644 --- a/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_partitioned_storage.py +++ b/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_partitioned_storage.py @@ -150,7 +150,11 @@ async def write(self, changes: Dict[str, object]): await self.initialize() for (key, change) in changes.items(): - e_tag = change.get("e_tag", None) + e_tag = None + if isinstance(change, dict): + e_tag = change.get("e_tag", None) + elif hasattr(change, "e_tag"): + e_tag = change.e_tag doc = { "id": CosmosDbKeyEscape.sanitize_key( key, self.config.key_suffix, self.config.compatibility_mode From f8046fc3a7a374d4240d7aa4f1047acb59b972e4 Mon Sep 17 00:00:00 2001 From: mdrichardson Date: Tue, 10 Dec 2019 11:56:05 -0800 Subject: [PATCH 5/5] fixed hasattr in CosmosDbStorage --- .../botbuilder/azure/cosmosdb_storage.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py b/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py index 7e405ca88..a5d01eea5 100644 --- a/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py +++ b/libraries/botbuilder-azure/botbuilder/azure/cosmosdb_storage.py @@ -183,11 +183,11 @@ async def write(self, changes: Dict[str, object]): # iterate over the changes for (key, change) in changes.items(): # store the e_tag - e_tag = ( - change.e_tag - if hasattr(change, "e_tag") - else change.get("e_tag", None) - ) + e_tag = None + if isinstance(change, dict): + e_tag = change.get("e_tag", None) + elif hasattr(change, "e_tag"): + e_tag = change.e_tag # create the new document doc = { "id": CosmosDbKeyEscape.sanitize_key(key),