Skip to content

[Core] Remove spurious ModuleNotFoundError in VM debug path#33355

Closed
Copilot wants to merge 2 commits into
devfrom
copilot/fix-module-not-found-error
Closed

[Core] Remove spurious ModuleNotFoundError in VM debug path#33355
Copilot wants to merge 2 commits into
devfrom
copilot/fix-module-not-found-error

Conversation

Copilot AI commented May 12, 2026

Copy link
Copy Markdown
Contributor

Related command
az vm list --debug

Description
VM commands under --debug were emitting a noisy ModuleNotFoundError (azure.mgmt.compute.v2024_03_03) while command execution still succeeded.
This PR aligns the Compute profile mapping with the actually shipped SDK module to remove the false traceback.

  • Profile mapping correction

    • Updated MGMT_COMPUTE gallery_image_versions API mapping from 2024-03-03 to 2024-03-02 in azure.cli.core.profiles._shared.
  • Regression coverage

    • Added a focused API-profile test that asserts the resolved SDK path for gallery_image_versions and verifies the module import succeeds.
sdk_path = get_versioned_sdk_path(
    'latest',
    ResourceType.MGMT_COMPUTE,
    operation_group='gallery_image_versions'
)
# now resolves to:
# "azure.mgmt.compute.v2024_03_02"

Testing Guide
Use the repro command:

  • az vm list --debug
    Expected: command behavior unchanged, and no debug traceback for missing azure.mgmt.compute.v2024_03_03.

History Notes
[Core] az vm list --debug: Remove spurious ModuleNotFoundError by correcting Compute gallery_image_versions profile API mapping.


This checklist is used to make sure that common guidelines for a pull request are followed.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • azcliprod.blob.core.windows.net
    • Triggering command: /usr/bin/python python -m unittest azure.cli.core.tests.test_api_profiles (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented May 12, 2026

Copy link
Copy Markdown
❌AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
❌vm
❌latest
❌3.12
Type Test Case Error Message Line
Failed test_image_version_end_of_life_date self = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
args = ['-g', 'cli_test_image_version_end_of_life_date_000001', '--gallery-name', 'gallery_000003', '--gallery-image-definition', 'image000004', ...]
namespace = Namespace(log_verbosity_verbose=False, log_verbosity_debug=False, log_verbosity_only_show_errors=False, output_for...ngeTag object at 0x7fba5d5823c0>, <azure.cli.core.breaking_change.UpcomingBreakingChangeTag object at 0x7fba5d581670>])
intermixed = False

    def parse_known_args2(self, args, namespace, intermixed):
        if args is None:
            # args default to the system args
            args = sys.argv[1:]
        else:
            # make sure that args are mutable
            args = list(args)
    
        # default Namespace built from parser defaults
        if namespace is None:
            namespace = Namespace()
    
        # add any action defaults that aren't present
        for action in self.actions:
            if action.dest is not SUPPRESS:
                if not hasattr(namespace, action.dest):
                    if action.default is not SUPPRESS:
                        setattr(namespace, action.dest, action.default)
    
        # add any parser defaults that aren't present
        for dest in self.defaults:
            if not hasattr(namespace, dest):
                setattr(namespace, dest, self.defaults[dest])
    
        # parse the arguments and exit if there are any errors
        if self.exit_on_error:
            try:
>               namespace, args = self.parse_known_args(args, namespace, intermixed)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1943: 
 
 
 
 
 
 
 
 
 
                               
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2184: in parse_known_args
    start_index = consume_optional(start_index)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2113: in consume_optional
    take_action(action, args, option_string)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2018: in take_action
    action(self, namespace, argument_values, option_string)
src/azure-cli-core/azure/cli/core/breaking_change.py:50: in call
    super().call(parser, namespace, values, option_string)
                                        

self = ArgumentBreakingChangeAction(option_strings=['--block-deletion-before-end-of-life'], dest='block_deletion_before_end_of_life', nargs='?', const=None, default=None, type=None, choices=None, required=False, help='==SUPPRESS==', metavar=None)
parser = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
namespace = Namespace(log_verbosity_verbose=False, log_verbosity_debug=False, log_verbosity_only_show_errors=False, output_for...ngeTag object at 0x7fba5d5823c0>, <azure.cli.core.breaking_change.UpcomingBreakingChangeTag object at 0x7fba5d581670>])
values = 'true', option_string = '--block-deletion-before-end-of-life'

    def call(self, parser, namespace, values, option_string=None):
>       raise argparse.ArgumentError(None, 'unrecognized argument: {} {}'.format(
            option_string, values or ''))
E       argparse.ArgumentError: unrecognized argument: --block-deletion-before-end-of-life true

env/lib/python3.12/site-packages/knack/arguments.py:477: ArgumentError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMGalleryImage testMethod=test_image_version_end_of_life_date>
resource_group = 'cli_test_image_version_end_of_life_date_000001'
resource_group_location = 'eastus'

    @AllowLargeResponse(size_kb=99999)
    @ResourceGroupPreparer(name_prefix='cli_test_image_version_end_of_life_date
', location='eastus')
    def test_image_version_end_of_life_date(self, resource_group, resource_group_location):
        self.kwargs.update({
            'vm': self.create_random_name('vm', 10),
            'gallery': self.create_random_name('gallery
', 20),
            'image': self.create_random_name('image', 15),
            'version': '1.1.1',
            'captured': self.create_random_name('captured', 15),
            'subnet': 'subnet1',
            'vnet': 'vnet1'
        })
        self.cmd('sig create -g {rg} --gallery-name {gallery}')
        self.cmd('sig image-definition create -g {rg} --gallery-name {gallery} --gallery-image-definition {image} --features SecurityType=Standard '
                 '--os-type linux -p publisher1 -f offer1 -s sku1 --hyper-v-generation v1', checks=[
            self.check('name', '{image}'),
            self.check('features', None),
        ])
        self.cmd('vm create -g {rg} -n {vm} --image Canonical:UbuntuServer:16.04-LTS:latest --admin-username clitest1 '
                 '--generate-ssh-key --subnet {subnet} --vnet-name {vnet} --size Standard_D2s_v3 --nsg-rule NONE')
    
        # Disable default outbound access
        self.cmd(
            'network vnet subnet update -g {rg} --vnet-name {vnet} -n {subnet} --default-outbound-access false')
    
        self.cmd('vm deallocate -g {rg} -n {vm}')
        self.cmd('vm generalize -g {rg} -n {vm}')
        self.cmd('image create -g {rg} -n {captured} --source {vm}')
>       self.cmd('sig image-version create -g {rg} --gallery-name {gallery} --gallery-image-definition {image} '
                 '--gallery-image-version {version} --managed-image {captured} --end-of-life-date "2026-12-31" --block-deletion-before-end-of-life true', checks=[
            self.check('safetyProfile.blockDeletionBeforeEndOfLife', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:8465: 
 
 
                                      
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: in in_process_execute
    self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
env/lib/python3.12/site-packages/knack/cli.py:250: in invoke
    raise ex
env/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:602: in execute
    parsed_args = self.parser.parse_args(args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
env/lib/python3.12/site-packages/knack/parser.py:261: in parse_args
    return super().parse_args(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1904: in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1914: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1943: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2165: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2141: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2018: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1272: in call
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1914: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1943: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2165: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2141: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2018: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1272: in call
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1914: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1943: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2165: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2141: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2018: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1272: in call
    subnamespace, arg_strings = parser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1914: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:1945: in parse_known_args2
    self.error(str(err))
src/azure-cli-core/azure/cli/core/parser.py:175: in error
    self.exit(2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
               _ 

self = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
status = 2, message = None

    def exit(self, status=0, message=None):
        if message:
            self._print_message(message, _sys.stderr)
>       _sys.exit(status)
E       SystemExit: 2

/opt/hostedtoolcache/Python/3.12.12/x64/lib/python3.12/argparse.py:2637: SystemExit
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:8436
❌3.13
Type Test Case Error Message Line
Failed test_image_version_end_of_life_date self = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
args = ['-g', 'cli_test_image_version_end_of_life_date_000001', '--gallery-name', 'gallery_000003', '--gallery-image-definition', 'image000004', ...]
namespace = Namespace(log_verbosity_verbose=False, log_verbosity_debug=False, log_verbosity_only_show_errors=False, output_for...ngeTag object at 0x7f497ee952b0>, <azure.cli.core.breaking_change.UpcomingBreakingChangeTag object at 0x7f49816a79d0>])
intermixed = False

    def parse_known_args2(self, args, namespace, intermixed):
        if args is None:
            # args default to the system args
            args = sys.argv[1:]
        else:
            # make sure that args are mutable
            args = list(args)
    
        # default Namespace built from parser defaults
        if namespace is None:
            namespace = Namespace()
    
        # add any action defaults that aren't present
        for action in self.actions:
            if action.dest is not SUPPRESS:
                if not hasattr(namespace, action.dest):
                    if action.default is not SUPPRESS:
                        setattr(namespace, action.dest, action.default)
    
        # add any parser defaults that aren't present
        for dest in self.defaults:
            if not hasattr(namespace, dest):
                setattr(namespace, dest, self.defaults[dest])
    
        # parse the arguments and exit if there are any errors
        if self.exit_on_error:
            try:
>               namespace, args = self.parse_known_args(args, namespace, intermixed)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1937: 
 
 
 
 
 
 
 
 
 
                               
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2188: in parse_known_args
    start_index = consume_optional(start_index)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2112: in consume_optional
    take_action(action, args, option_string)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2013: in take_action
    action(self, namespace, argument_values, option_string)
src/azure-cli-core/azure/cli/core/breaking_change.py:50: in call
    super().call(parser, namespace, values, option_string)
                                        

self = ArgumentBreakingChangeAction(option_strings=['--block-deletion-before-end-of-life'], dest='block_deletion_before_end_o...const=None, default=None, type=None, choices=None, required=False, help='==SUPPRESS==', metavar=None, deprecated=False)
parser = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
namespace = Namespace(log_verbosity_verbose=False, log_verbosity_debug=False, log_verbosity_only_show_errors=False, output_for...ngeTag object at 0x7f497ee952b0>, <azure.cli.core.breaking_change.UpcomingBreakingChangeTag object at 0x7f49816a79d0>])
values = 'true', option_string = '--block-deletion-before-end-of-life'

    def call(self, parser, namespace, values, option_string=None):
>       raise argparse.ArgumentError(None, 'unrecognized argument: {} {}'.format(
            option_string, values or ''))
E       argparse.ArgumentError: unrecognized argument: --block-deletion-before-end-of-life true

env/lib/python3.13/site-packages/knack/arguments.py:477: ArgumentError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMGalleryImage testMethod=test_image_version_end_of_life_date>
resource_group = 'cli_test_image_version_end_of_life_date_000001'
resource_group_location = 'eastus'

    @AllowLargeResponse(size_kb=99999)
    @ResourceGroupPreparer(name_prefix='cli_test_image_version_end_of_life_date
', location='eastus')
    def test_image_version_end_of_life_date(self, resource_group, resource_group_location):
        self.kwargs.update({
            'vm': self.create_random_name('vm', 10),
            'gallery': self.create_random_name('gallery
', 20),
            'image': self.create_random_name('image', 15),
            'version': '1.1.1',
            'captured': self.create_random_name('captured', 15),
            'subnet': 'subnet1',
            'vnet': 'vnet1'
        })
        self.cmd('sig create -g {rg} --gallery-name {gallery}')
        self.cmd('sig image-definition create -g {rg} --gallery-name {gallery} --gallery-image-definition {image} --features SecurityType=Standard '
                 '--os-type linux -p publisher1 -f offer1 -s sku1 --hyper-v-generation v1', checks=[
            self.check('name', '{image}'),
            self.check('features', None),
        ])
        self.cmd('vm create -g {rg} -n {vm} --image Canonical:UbuntuServer:16.04-LTS:latest --admin-username clitest1 '
                 '--generate-ssh-key --subnet {subnet} --vnet-name {vnet} --size Standard_D2s_v3 --nsg-rule NONE')
    
        # Disable default outbound access
        self.cmd(
            'network vnet subnet update -g {rg} --vnet-name {vnet} -n {subnet} --default-outbound-access false')
    
        self.cmd('vm deallocate -g {rg} -n {vm}')
        self.cmd('vm generalize -g {rg} -n {vm}')
        self.cmd('image create -g {rg} -n {captured} --source {vm}')
>       self.cmd('sig image-version create -g {rg} --gallery-name {gallery} --gallery-image-definition {image} '
                 '--gallery-image-version {version} --managed-image {captured} --end-of-life-date "2026-12-31" --block-deletion-before-end-of-life true', checks=[
            self.check('safetyProfile.blockDeletionBeforeEndOfLife', True)
        ])

src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:8465: 
 
 
                                      
src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in init
    self.in_process_execute(cli_ctx, command, expect_failure=expect_failure)
src/azure-cli-testsdk/azure/cli/testsdk/base.py:303: in in_process_execute
    self.exit_code = cli_ctx.invoke(shlex.split(command), out_file=stdout_buf) or 0
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
env/lib/python3.13/site-packages/knack/cli.py:250: in invoke
    raise ex
env/lib/python3.13/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/commands/init.py:602: in execute
    parsed_args = self.parser.parse_args(args)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
env/lib/python3.13/site-packages/knack/parser.py:261: in parse_args
    return super().parse_args(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1898: in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1908: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1937: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2169: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2144: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2013: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1258: in call
    subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1908: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1937: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2169: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2144: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2013: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1258: in call
    subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1908: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1937: in parse_known_args2
    namespace, args = self.parse_known_args(args, namespace, intermixed)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2169: in parse_known_args
    positionals_end_index = consume_positionals(start_index)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2144: in consume_positionals
    take_action(action, args)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2013: in take_action
    action(self, namespace, argument_values, option_string)
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1258: in call
    subnamespace, arg_strings = subparser.parse_known_args(arg_strings, None)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/azure-cli-core/azure/cli/core/parser.py:282: in parse_known_args
    self.namespace, self.raw_arguments = super().parse_known_args(args=args, namespace=namespace)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1908: in parse_known_args
    return self.parse_known_args2(args, namespace, intermixed=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:1939: in parse_known_args2
    self.error(str(err))
src/azure-cli-core/azure/cli/core/parser.py:175: in error
    self.exit(2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
               _ 

self = AzCliCommandParser(prog='az sig image-version create', usage=None, description='', formatter_class=<class 'argparse.HelpFormatter'>, conflict_handler='error', add_help=True)
status = 2, message = None

    def exit(self, status=0, message=None):
        if message:
            self._print_message(message, _sys.stderr)
>       _sys.exit(status)
E       SystemExit: 2

/opt/hostedtoolcache/Python/3.13.11/x64/lib/python3.13/argparse.py:2645: SystemExit
azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:8436

@azure-client-tools-bot-prd

azure-client-tools-bot-prd Bot commented May 12, 2026

Copy link
Copy Markdown
️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

Copilot AI changed the title [WIP] Fix ModuleNotFoundError on vm commands with debug flag [Core] Remove spurious ModuleNotFoundError in VM debug path May 12, 2026
Copilot finished work on behalf of a0x1ab May 12, 2026 04:50
Copilot AI requested a review from a0x1ab May 12, 2026 04:50
@yonzhan

yonzhan commented May 12, 2026

Copy link
Copy Markdown
Collaborator

VM

@azclibot

Copy link
Copy Markdown
Collaborator

Closing this PR. It was generated by an earlier version of our automated bug-fix pipeline whose live-test step ran whole-module tests, which produced mis-targeted and environmental failures unrelated to the change. The pipeline now runs only the test files touched by the PR. This issue will be re-worked from scratch by the updated pipeline.

@azclibot azclibot closed this Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ModuleNotFoundError on vm commands when using --debug flag

6 participants