From f37f820824805d8cc20d4fc28cd8e280e8f89e41 Mon Sep 17 00:00:00 2001 From: Zhiyi Huang <17182306+calvinhzy@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:23:41 +0800 Subject: [PATCH] Update _validators.py --- .../azure/cli/command_modules/storage/_validators.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/storage/_validators.py b/src/azure-cli/azure/cli/command_modules/storage/_validators.py index 0ab62590c3f..745dbcfc0bb 100644 --- a/src/azure-cli/azure/cli/command_modules/storage/_validators.py +++ b/src/azure-cli/azure/cli/command_modules/storage/_validators.py @@ -617,6 +617,7 @@ def validator(cmd, namespace): clear_content_settings = ns.pop('clear_content_settings', False) # retrieve the existing object properties for an update + props = None if update and not clear_content_settings: account = ns.get('account_name') key = ns.get('account_key') @@ -672,12 +673,12 @@ def validator(cmd, namespace): ) # if update, fill in any None values with existing - if update: + if update and props: if not clear_content_settings: for attr in ['content_type', 'content_disposition', 'content_encoding', 'content_language', 'content_md5', 'cache_control']: if getattr(new_props, attr) is None: - setattr(new_props, attr, getattr(props, attr)) # pylint: disable=used-before-assignment + setattr(new_props, attr, getattr(props, attr)) else: if guess_from_file: new_props = guess_content_type(ns[guess_from_file], new_props, settings_class)