Skip to content

register_argument_deprecate fails: AttributeError: 'AzCliCommandInvoker' object has no attribute 'command_loader'. #31047

@jiasli

Description

@jiasli

Describe the bug

Create src/azure-cli/azure/cli/command_modules/role/_breaking_change.py with

from azure.cli.core.breaking_change import register_argument_deprecate

register_argument_deprecate('role assignment list', '--all')

Running az role assignment list -h fails:

  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\breaking_change.py", line 27, in _get_action_class
    action_class = cli_ctx.invocation.command_loader.cli_ctx.invocation.parser._registries['action'][action]  # pylint: disable=protected-access
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AzCliCommandInvoker' object has no attribute 'command_loader'. Did you mean: 'commands_loader'?

Related command

az role assignment list -h

Errors

> az role assignment list -h
The command failed with an unexpected error. Here is the traceback:
'AzCliCommandInvoker' object has no attribute 'command_loader'
Traceback (most recent call last):
  File "D:\cli\py312\Lib\site-packages\knack\cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\commands\__init__.py", line 566, in execute
    self.cli_ctx.raise_event(EVENT_INVOKER_POST_CMD_TBL_CREATE, commands_loader=self.commands_loader)
  File "D:\cli\py312\Lib\site-packages\knack\cli.py", line 170, in raise_event
    func(self, **kwargs)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\breaking_change.py", line 539, in update_breaking_change_info
    breaking_change.register(cli_ctx)
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\breaking_change.py", line 249, in register
    arg.action = _argument_breaking_change_action(cli_ctx, arg.deprecate_info, arg.options['action'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\breaking_change.py", line 33, in _argument_breaking_change_action
    action_class = _get_action_class(cli_ctx, action)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\cli\azure-cli\src\azure-cli-core\azure\cli\core\breaking_change.py", line 27, in _get_action_class
    action_class = cli_ctx.invocation.command_loader.cli_ctx.invocation.parser._registries['action'][action]  # pylint: disable=protected-access
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AzCliCommandInvoker' object has no attribute 'command_loader'. Did you mean: 'commands_loader'?

Issue script & Debug output

NA

Expected behavior

Should succeed.

Environment Summary

az --version
azure-cli 2.70.0

core 2.70.0
telemetry 1.1.0

Extensions:
ssh 2.0.6

Dependencies:
msal 1.31.2b1
azure-mgmt-resource 23.1.1

Python location 'D:\cli\py312\Scripts\python.exe'
Config directory 'C:\Users\xxx.azure'
Extensions directory 'C:\Users\xxx.azure\cliextensions'

Python (Windows) 3.12.9 (tags/v3.12.9:fdb8142, Feb 4 2025, 15:27:58) [MSC v.1942 64 bit (AMD64)]

Additional context

No response

Metadata

Metadata

Assignees

Labels

Auto-AssignAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamRBACaz rolequestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions