Skip to content

az login error after authentication in browser - json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31) #33720

Open

Description

@thomasvdb

Describe the bug

While I didn't upgrade the Azure CLI recently, it suddenly started failing.
I always use the plain az login command which then opens the browser (Firefox in this case) to authenticate.

The authentication succeeds and after returning to the terminal the error is shown.
However, it seems I'm logged in even after this error as I can execute the required actions afterwards.

I tried upgrading to the latest Azure CLI version with Homebrew but to no avail.

Related command

az login

Errors

The command failed with an unexpected error. Here is the traceback:
Extra data: line 3 column 8 (char 31)
Traceback (most recent call last):
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 677, in execute
    raise ex
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 789, in _run_job
    result = cmd_copy(params)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 335, in __call__
    return self.handler(*args, **kwargs)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
    return op(**command_args)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/profile/custom.py", line 215, in login
    subscriptions = profile.login(
        interactive,
    ...<11 lines>...
        subscription=subscription
    )
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/_profile.py", line 179, in login
    user_identity = identity.login_with_auth_code(scopes=scopes, claims_challenge=claims_challenge)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/auth/identity.py", line 166, in login_with_auth_code
    result = self._msal_app.acquire_token_interactive(
        scopes, prompt='select_account', port=8400 if self._is_adfs else None,
    ...<2 lines>...
        enable_msa_passthrough=True,
        claims_challenge=claims_challenge)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 2263, in acquire_token_interactive
    response = _clean_up(self.client.obtain_token_by_browser(
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        scope=self._decorate_scope(scopes) if scopes else None,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<14 lines>...
        browser_name=_preferred_browser(),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        **kwargs))
        ^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 334, in obtain_token_by_browser
    return super(Client, self).obtain_token_by_browser(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        auth_params=dict(kwargs.pop("auth_params", {}), **filtered_params),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        **kwargs)
        ^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 655, in obtain_token_by_browser
    return self._obtain_token_by_browser(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        receiver, redirect_uri=uri, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 696, in _obtain_token_by_browser
    return self.obtain_token_by_auth_code_flow(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        flow, auth_response, scope=scope, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 203, in obtain_token_by_auth_code_flow
    return super(_ClientWithCcsRoutingInfo, self).obtain_token_by_auth_code_flow(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        auth_code_flow, auth_response, headers=headers, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 258, in obtain_token_by_auth_code_flow
    result = super(Client, self).obtain_token_by_auth_code_flow(
        auth_code_flow, auth_response, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 563, in obtain_token_by_auth_code_flow
    return self._obtain_token_by_authorization_code(
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
        auth_response["code"],
        ^^^^^^^^^^^^^^^^^^^^^^
    ...<10 lines>...
            ),
            ^^
        **kwargs)
        ^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 750, in _obtain_token_by_authorization_code
    return self._obtain_token("authorization_code", data=data, **kwargs)
           ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 169, in _obtain_token
    ret = super(Client, self)._obtain_token(grant_type, *args, **kwargs)
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 807, in _obtain_token
    (on_obtaining_tokens or self.on_obtaining_tokens)({
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
        "client_id": self.client_id,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<4 lines>...
        "response": _resp, "params": params, "data": _data,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        })
        ^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 884, in <lambda>
    on_obtaining_tokens=lambda event: self.token_cache.add(dict(
                                      ~~~~~~~~~~~~~~~~~~~~^^^^^^
        event, environment=authority.instance)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 530, in add
    super(SerializableTokenCache, self).add(event, **kwargs)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 317, in add
    return self.__add(event, now=now)
           ~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 390, in __add
    self.modify(self.CredentialType.ACCESS_TOKEN, at, at)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 70, in modify
    self._reload_if_necessary()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 61, in _reload_if_necessary
    self.deserialize(self._persistence.load())
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 542, in deserialize
    self._cache = json.loads(state) if state else {}
                  ~~~~~~~~~~^^^^^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/__init__.py", line 352, in loads
    return _default_decoder.decode(s)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/decoder.py", line 348, in decode
    raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31)

Issue script & Debug output

cli.knack.cli: Command arguments: ['login', '--debug']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x107b74930>, <function OutputProducer.on_global_arguments at 0x107c96c40>, <function CLIQuery.on_global_arguments at 0x107cc9430>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Using packaged command index for profile 'latest'.
cli.azure.cli.core: Found installed extension 'redisenterprise' (azext_redisenterprise).
cli.azure.cli.core: Blending packaged core index with local extension index.
cli.azure.cli.core: Modules found from index for 'login': ['azure.cli.command_modules.profile']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: profile 0.004 2 8
cli.azure.cli.core: Loaded command modules:
cli.azure.cli.core: Total (1) 0.004 2 8
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: Loaded 2 groups, 8 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : login
cli.azure.cli.core: Command table: login
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x107eb4f60>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/thomasvandenbossche/.azure/commands/2026-07-10.11-58-14.login.27793.log'.
az_command_data_logger: command args: login --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x107f72ae0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x107f72c40>, <function register_global_policy_argument..add_global_policy_argument at 0x107f95f30>, <function register_cache_arguments..add_cache_arguments at 0x107f95fe0>, <function register_upcoming_breaking_change_info..update_breaking_change_info at 0x107f96090>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x107c96cf0>, <function CLIQuery.handle_query_parameter at 0x107cc94e0>, <function register_ids_argument..parse_ids_arguments at 0x107f95e80>]
cli.azure.cli.core.auth.persistence: build_persistence: location='/Users/thomasvandenbossche/.azure/msal_token_cache.json', encrypt=False
cli.azure.cli.core.auth.binary_cache: load: /Users/thomasvandenbossche/.azure/msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
msal.application: Broker enabled? None
cli.azure.cli.core.auth.identity: A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with az login --use-device-code.
msal.telemetry: Generate or reuse correlation_id: 56887de0-2089-4119-9cc4-c816d6fc5965
msal.oauth2cli.oauth2: Using http://localhost:63100 as redirect_uri
msal.oauth2cli.authcode: Abort by visit http://localhost:63100?error=abort
msal.oauth2cli.authcode: Open a browser on this device to visit: [redacted]
msal.oauth2cli.authcode: Got auth response: [redacted]
msal.oauth2cli.authcode: "POST / HTTP/1.1" 200 -
urllib3.connectionpool: Starting new HTTPS connection (1): login.microsoftonline.com:443
urllib3.connectionpool: https://login.microsoftonline.com:443 "POST /organizations/oauth2/v2.0/token HTTP/1.1" 200 10213
msal.token_cache: event={
[redacted]
}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 677, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 820, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 789, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 335, in call
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/profile/custom.py", line 215, in login
subscriptions = profile.login(
interactive,
...<11 lines>...
subscription=subscription
)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/_profile.py", line 179, in login
user_identity = identity.login_with_auth_code(scopes=scopes, claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/auth/identity.py", line 166, in login_with_auth_code
result = self._msal_app.acquire_token_interactive(
scopes, prompt='select_account', port=8400 if self._is_adfs else None,
...<2 lines>...
enable_msa_passthrough=True,
claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 2263, in acquire_token_interactive
response = _clean_up(self.client.obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
scope=self._decorate_scope(scopes) if scopes else None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<14 lines>...
browser_name=_preferred_browser(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs))
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 334, in obtain_token_by_browser
return super(Client, self).obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_params=dict(kwargs.pop("auth_params", {}), **filtered_params),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 655, in obtain_token_by_browser
return self._obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
receiver, redirect_uri=uri, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 696, in _obtain_token_by_browser
return self.obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
flow, auth_response, scope=scope, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 203, in obtain_token_by_auth_code_flow
return super(_ClientWithCcsRoutingInfo, self).obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_code_flow, auth_response, headers=headers, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 258, in obtain_token_by_auth_code_flow
result = super(Client, self).obtain_token_by_auth_code_flow(
auth_code_flow, auth_response, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 563, in obtain_token_by_auth_code_flow
return self._obtain_token_by_authorization_code(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_response["code"],
^^^^^^^^^^^^^^^^^^^^^^
...<10 lines>...
),
^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 750, in _obtain_token_by_authorization_code
return self._obtain_token("authorization_code", data=data, **kwargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 169, in _obtain_token
ret = super(Client, self)._obtain_token(grant_type, *args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 807, in _obtain_token
(on_obtaining_tokens or self.on_obtaining_tokens)({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
"client_id": self.client_id,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
"response": _resp, "params": params, "data": _data,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})
^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 884, in
on_obtaining_tokens=lambda event: self.token_cache.add(dict(
~~~~~~~~~~~~~~~~~~~~^^^^^^
event, environment=authority.instance)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 530, in add
super(SerializableTokenCache, self).add(event, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 317, in add
return self.__add(event, now=now)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 390, in __add
self.modify(self.CredentialType.ACCESS_TOKEN, at, at)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 70, in modify
self._reload_if_necessary()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 61, in _reload_if_necessary
self.deserialize(self._persistence.load())
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 542, in deserialize
self._cache = json.loads(state) if state else {}
~~~~~~~~~~^^^^^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/init.py", line 352, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/decoder.py", line 348, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31)

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: Extra data: line 3 column 8 (char 31)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 677, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 820, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 789, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 335, in call
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/profile/custom.py", line 215, in login
subscriptions = profile.login(
interactive,
...<11 lines>...
subscription=subscription
)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/_profile.py", line 179, in login
user_identity = identity.login_with_auth_code(scopes=scopes, claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/auth/identity.py", line 166, in login_with_auth_code
result = self._msal_app.acquire_token_interactive(
scopes, prompt='select_account', port=8400 if self._is_adfs else None,
...<2 lines>...
enable_msa_passthrough=True,
claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 2263, in acquire_token_interactive
response = _clean_up(self.client.obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
scope=self._decorate_scope(scopes) if scopes else None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<14 lines>...
browser_name=_preferred_browser(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs))
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 334, in obtain_token_by_browser
return super(Client, self).obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_params=dict(kwargs.pop("auth_params", {}), **filtered_params),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 655, in obtain_token_by_browser
return self._obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
receiver, redirect_uri=uri, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 696, in _obtain_token_by_browser
return self.obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
flow, auth_response, scope=scope, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 203, in obtain_token_by_auth_code_flow
return super(_ClientWithCcsRoutingInfo, self).obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_code_flow, auth_response, headers=headers, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 258, in obtain_token_by_auth_code_flow
result = super(Client, self).obtain_token_by_auth_code_flow(
auth_code_flow, auth_response, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 563, in obtain_token_by_auth_code_flow
return self._obtain_token_by_authorization_code(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_response["code"],
^^^^^^^^^^^^^^^^^^^^^^
...<10 lines>...
),
^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 750, in _obtain_token_by_authorization_code
return self._obtain_token("authorization_code", data=data, **kwargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 169, in _obtain_token
ret = super(Client, self)._obtain_token(grant_type, *args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 807, in _obtain_token
(on_obtaining_tokens or self.on_obtaining_tokens)({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
"client_id": self.client_id,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
"response": _resp, "params": params, "data": _data,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})
^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 884, in
on_obtaining_tokens=lambda event: self.token_cache.add(dict(
~~~~~~~~~~~~~~~~~~~~^^^^^^
event, environment=authority.instance)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 530, in add
super(SerializableTokenCache, self).add(event, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 317, in add
return self.__add(event, now=now)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 390, in __add
self.modify(self.CredentialType.ACCESS_TOKEN, at, at)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 70, in modify
self._reload_if_necessary()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 61, in _reload_if_necessary
self.deserialize(self._persistence.load())
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 542, in deserialize
self._cache = json.loads(state) if state else {}
~~~~~~~~~~^^^^^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/init.py", line 352, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/decoder.py", line 348, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31)
az_command_data_logger: Extra data: line 3 column 8 (char 31)
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 677, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 820, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 789, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/init.py", line 335, in call
return self.handler(*args, **kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
return op(**command_args)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/profile/custom.py", line 215, in login
subscriptions = profile.login(
interactive,
...<11 lines>...
subscription=subscription
)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/_profile.py", line 179, in login
user_identity = identity.login_with_auth_code(scopes=scopes, claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/auth/identity.py", line 166, in login_with_auth_code
result = self._msal_app.acquire_token_interactive(
scopes, prompt='select_account', port=8400 if self._is_adfs else None,
...<2 lines>...
enable_msa_passthrough=True,
claims_challenge=claims_challenge)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 2263, in acquire_token_interactive
response = _clean_up(self.client.obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
scope=self._decorate_scope(scopes) if scopes else None,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<14 lines>...
browser_name=_preferred_browser(),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs))
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 334, in obtain_token_by_browser
return super(Client, self).obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_params=dict(kwargs.pop("auth_params", {}), **filtered_params),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 655, in obtain_token_by_browser
return self._obtain_token_by_browser(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
receiver, redirect_uri=uri, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 696, in _obtain_token_by_browser
return self.obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
flow, auth_response, scope=scope, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 203, in obtain_token_by_auth_code_flow
return super(_ClientWithCcsRoutingInfo, self).obtain_token_by_auth_code_flow(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_code_flow, auth_response, headers=headers, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 258, in obtain_token_by_auth_code_flow
result = super(Client, self).obtain_token_by_auth_code_flow(
auth_code_flow, auth_response, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 563, in obtain_token_by_auth_code_flow
return self._obtain_token_by_authorization_code(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
auth_response["code"],
^^^^^^^^^^^^^^^^^^^^^^
...<10 lines>...
),
^^
**kwargs)
^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 750, in _obtain_token_by_authorization_code
return self._obtain_token("authorization_code", data=data, **kwargs)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oidc.py", line 169, in _obtain_token
ret = super(Client, self)._obtain_token(grant_type, *args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/oauth2cli/oauth2.py", line 807, in _obtain_token
(on_obtaining_tokens or self.on_obtaining_tokens)({
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
"client_id": self.client_id,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<4 lines>...
"response": _resp, "params": params, "data": _data,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
})
^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 884, in
on_obtaining_tokens=lambda event: self.token_cache.add(dict(
~~~~~~~~~~~~~~~~~~~~^^^^^^
event, environment=authority.instance)),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 530, in add
super(SerializableTokenCache, self).add(event, **kwargs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 317, in add
return self.__add(event, now=now)
~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 390, in __add
self.modify(self.CredentialType.ACCESS_TOKEN, at, at)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 70, in modify
self._reload_if_necessary()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 61, in _reload_if_necessary
self.deserialize(self._persistence.load())
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 542, in deserialize
self._cache = json.loads(state) if state else {}
~~~~~~~~~~^^^^^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/init.py", line 352, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/decoder.py", line 348, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31)
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x107eb5220>]
az_command_data_logger: exit code: 1
cli.main: Command ran in 3.781 seconds (init: 0.086, invoke: 3.695)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 8377 in cache file under /Users/thomasvandenbossche/.azure/telemetry/20260710115818036
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/telemetry/init.py /Users/thomasvandenbossche/.azure /Users/thomasvandenbossche/.azure/telemetry/20260710115818036"
telemetry.process: Return from creating process 27807
telemetry.main: Finish creating telemetry upload process.

Expected behavior

I can successfully login.

Environment Summary

azure-cli 2.88.0

core 2.88.0
telemetry 1.1.0

Extensions:
redisenterprise 1.4.0

Dependencies:
msal 1.36.0
azure-mgmt-resource 24.0.0

Python location '/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/bin/python'
Config directory '/Users/thomasvandenbossche/.azure'
Extensions directory '/Users/thomasvandenbossche/.azure/cliextensions'

Python (Darwin) 3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

Activity

  1. added
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Jul 10, 2026
  2. added
    customer-reportedIssues that are reported by GitHub users external to the Azure organization.
    Accountaz login/account
    Azure CLI TeamThe command of the issue is owned by Azure CLI team
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Jul 10, 2026
  3. removed
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Jul 10, 2026
  4. added this to the Backlog milestone on Jul 10, 2026
  5. yonzhan commented on Jul 10, 2026

    @yonzhan
    Collaborator

    az login

  6. notyashhh commented on Jul 14, 2026

    @notyashhh
    Member

    Hi thomasvdb, thanks for the detailed traceback.

    The error happens after your token is successfully acquired — the CLI then reloads ~/.azure/msal_token_cache.json and finds it contains extra data past the end of the JSON, which points to a corrupted or partially-written cache file. That's why you remain logged in despite the error.

    As a workaround, please clear the local cache and log in again:

    az account clear
    rm -f ~/.azure/msal_token_cache.json
    az login
    

    If the error returns after this, please let us know — that would indicate something is repeatedly corrupting the cache file (e.g. concurrent az processes), and we'll dig in further.

  7. thomasvdb commented on Jul 14, 2026

    @thomasvdb
    Author

    Yash (@notyashhh) I've just run az account clear and I got the following error:

    The command failed with an unexpected error. Here is the traceback:
    Extra data: line 3 column 8 (char 31)
    Traceback (most recent call last):
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/knack/cli.py", line 233, in invoke
        cmd_result = self.invocation.execute(args)
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 677, in execute
        raise ex
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 820, in _run_jobs_serially
        results.append(self._run_job(expanded_arg, cmd_copy))
                       ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 789, in _run_job
        result = cmd_copy(params)
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/__init__.py", line 335, in __call__
        return self.handler(*args, **kwargs)
               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/commands/command_operation.py", line 120, in handler
        return op(**command_args)
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/profile/custom.py", line 120, in account_clear
        profile.logout_all()
        ~~~~~~~~~~~~~~~~~~^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/_profile.py", line 333, in logout_all
        identity.logout_all_users()
        ~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/auth/identity.py", line 209, in logout_all_users
        accounts = self._msal_app.get_accounts()
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 1262, in get_accounts
        accounts = self._find_msal_accounts(environment=self.authority.instance)
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/application.py", line 1305, in _find_msal_accounts
        for a in self.token_cache.search(
                 ~~~~~~~~~~~~~~~~~~~~~~~^
            TokenCache.CredentialType.ACCOUNT,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            query={"environment": environment})
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 83, in search
        self._reload_if_necessary()
        ~~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal_extensions/token_cache.py", line 61, in _reload_if_necessary
        self.deserialize(self._persistence.load())
        ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/msal/token_cache.py", line 542, in deserialize
        self._cache = json.loads(state) if state else {}
                      ~~~~~~~~~~^^^^^^^
      File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/__init__.py", line 352, in loads
        return _default_decoder.decode(s)
               ~~~~~~~~~~~~~~~~~~~~~~~^^^
      File "/opt/homebrew/Cellar/python@3.14/3.14.6/Frameworks/Python.framework/Versions/3.14/lib/python3.14/json/decoder.py", line 348, in decode
        raise JSONDecodeError("Extra data", s, end)
    json.decoder.JSONDecodeError: Extra data: line 3 column 8 (char 31)
    

    I've continued with the next steps but still getting the error on az login

  8. 2 remaining items

  9. x-engineering-agent commented on Jul 15, 2026

    @x-engineering-agent
    Contributor

    X Engineering Agent Bug analysis: Root cause analysis

    az login succeeds (the token is acquired and the user is authenticated), but the CLI then raises an unhandled json.decoder.JSONDecodeError: Extra data while reloading the local MSAL token cache. The traceback shows the failure originates in the persistence/reload path:

    azure/cli/command_modules/profile/custom.py -> login()
      -> azure/cli/core/_profile.py -> Profile.login()
        -> azure/cli/core/auth/identity.py -> Identity.login_with_auth_code()
          -> msal.application.acquire_token_interactive() (token acquired OK)
            -> msal.token_cache.SerializableTokenCache.add()
              -> msal_extensions/token_cache.py -> _reload_if_necessary()
                -> self.deserialize(self._persistence.load())  # raises JSONDecodeError
    

    A maintainer confirmed in the comments: the CLI reloads ~/.azure/msal_token_cache.json after acquiring the token, and the file contains trailing/extra data beyond valid JSON (a corrupted or partially-written cache file), which crashes json.loads. The user remains logged in because the token was already acquired before the crash — only the cache-reload step fails.

    The reporter also confirmed az account clear also fails with the same error when the cache is already corrupted (see logout_all_users() -> get_accounts() -> same reload path), meaning the current workaround (manually deleting ~/.azure/msal_token_cache.json before running az account clear) is required and there's no in-CLI recovery.

    Expected fix: the token cache reload/deserialize path in azure/cli/core/auth/identity.py (or wherever the CLI wraps SerializableTokenCache/msal_extensions persistence) should catch json.decoder.JSONDecodeError (and similarly malformed/corrupted cache content) when reloading the cache, log a warning, and reset/recreate the cache file instead of letting the exception propagate and abort the command — for both az login and az account clear/logout_all_users().

    Reproduction:

    az login   # succeeds interactively, but raises JSONDecodeError from the token cache reload
    az account clear   # also raises the same JSONDecodeError if the cache is already corrupted
    

    Use this EXACT PR title: [Profile] Fix #33720: az login: Handle corrupted MSAL token cache instead of raising JSONDecodeError

    PR title & description format (required)

    This repo enforces a PR format (guide). Please author the PR exactly as follows or CI's Check the Format of Pull Request Title and Content will fail.

    Use this EXACT PR title (copy verbatim, do not reword):

    [Profile] Fix #33720: `az login`: Handle corrupted MSAL token cache instead of raising JSONDecodeError
    

    Keep the backticks around the command and the Fix #33720: prefix. You may only adjust the wording after the command (the final summary) if the fix changes; the [Profile] prefix, issue link, and backticked command must stay.

    Description — follow the PR template and fill in:

    • Link the issue — start the Description with a closing keyword so the PR auto-links and closes it: Fixes #33720.
    • Related command — the az ... command this affects.
    • Description (mandatory) — why the bug happens, what you changed, and the resulting behavior.
    • Testing Guide — example command(s) showing the fix works.
    • History Notes — leave the title to drive the history note, or add extra lines in the same format (component in brackets + the command in backticks), e.g. [Profile] `az <command>`: <note>.
    • Keep the template checklist and tick the items you've satisfied.

    X Engineering Agent · Fixer · react 👍 / 👎 to train the agent

  10. microsoft-github-policy-service commented on Jul 15, 2026

    @microsoft-github-policy-service
    Contributor

    🔔 Routing this issue to @Azure/act-identity-squad.

  11. thomasvdb commented on Jul 16, 2026

    @thomasvdb
    Author

    Chris Boe (@Chris-Boe) It seems I just don't have the msal_token_cache.json at all?

    # cd ∼/.azure
    cd: no such file or directory: ∼/.azure
    
  12. thomasvdb commented on Jul 16, 2026

    @thomasvdb
    Author

    Chris Boe (@Chris-Boe) Nevermind, found the directory, cleared the file and it's OK now!

  13. thorfi commented on Aug 20, 2026

    @thorfi

    Bump, still a real issue (I just had it) - the rm -f ~/.azure/msal_token_cache.json workaround works though.

  14. x-engineering-agent commented on Oct 15, 2026

    @x-engineering-agent
    Contributor

    ⏳ Queued — X Engineering Agent picked up this request and will post its findings here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Accountaz login/accountAuto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamact-identity-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionThis issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions