diff --git a/src/azure-cli-core/azure/cli/core/auth/binary_cache.py b/src/azure-cli-core/azure/cli/core/auth/binary_cache.py index 3f4832678fc..e56c95b130f 100644 --- a/src/azure-cli-core/azure/cli/core/auth/binary_cache.py +++ b/src/azure-cli-core/azure/cli/core/auth/binary_cache.py @@ -42,10 +42,11 @@ def load(self): logger.debug("load: %s", self.filename) try: self.data = self._load() - except (pickle.UnpicklingError, EOFError) as ex: - # We still get exception after retry: + except Exception as ex: # pylint: disable=broad-exception-caught + # If we still get exception after retry, ignore all types of exceptions and use a new cache. # - pickle.UnpicklingError is caused by corrupted cache file, perhaps due to concurrent writes. # - EOFError is caused by empty cache file created by other az instance, but hasn't been filled yet. + # - AttributeError is caused by reading cache generated by different MSAL versions. logger.debug("Failed to load cache: %s. Using a fresh one.", ex) self.data = {} # Ignore a non-existing or corrupted http_cache