Skip to content
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
4 changes: 3 additions & 1 deletion src/azure-cli-core/azure/cli/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ def hash256_result(func):
@wraps(func)
def _decorator(*args, **kwargs):
val = func(*args, **kwargs)
if not val:
if val is None:
raise ValueError('Return value is None')
if not isinstance(val, str):
raise ValueError('Return value is not string')
if not val:
return val
hash_object = hashlib.sha256(val.encode('utf-8'))
return str(hash_object.hexdigest())

Expand Down
12 changes: 9 additions & 3 deletions src/azure-cli-core/azure/cli/core/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import uuid
from collections import defaultdict
from functools import wraps

from knack.util import CLIError
import azure.cli.core.decorators as decorators

PRODUCT_NAME = 'azurecli'
Expand Down Expand Up @@ -527,7 +527,10 @@ def _get_hash_machine_id():
@decorators.suppress_all_exceptions(fallback_return='')
@decorators.hash256_result
def _get_user_azure_id():
return _get_profile().get_current_account_user()
try:
return _get_profile().get_current_account_user()
except CLIError:
return ''


def _get_env_string():
Expand All @@ -537,7 +540,10 @@ def _get_env_string():

@decorators.suppress_all_exceptions(fallback_return=None)
def _get_azure_subscription_id():
return _get_profile().get_subscription_id()
try:
return _get_profile().get_subscription_id()
except CLIError:
return None


def _get_shell_type():
Expand Down