Azure / Azure/azure-cli-extensions

[vm-repair] [vm-repair] repair-button command fails with FrameLocalsProxy error in CLI >= 2.77.0

Open
#9,971 3 comments 1 reaction 3 assignees Claimed by @yanzhudd View on GitHub
Auto-Assign Azure CLI Team Compute question
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

Source: https://github.com/Azure/azure-cli/issues/32408 (by @PaladhiDinesh)
Affected extension: `vm-repair` (`src/vm-repair/`)

---

<<>>
# Issue #32408 (by @PaladhiDinesh)
## Title
[vm-repair] repair-button command fails with FrameLocalsProxy error in CLI >= 2.77.0

## Body
### Describe the bug

The az vm repair repair-button command fails when using Azure CLI versions 2.77.0 and above. The same command works correctly in Azure Cloud Shell(which has 2.77.0) and with CLI versions up to 2.76.0. This issue impacts automated repair workflows and SRE agent scenarios, especially for VMs with fstab issues.

### Related command

az vm repair repair-button --button-command 'fstab' --verbose --resource-group --name

### Errors

PS C:\Users\dpaladhi> az vm repair repair-button --button-command 'fstab' --resource-group nobootscenariosrg --name fstabnoboot
This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus
The command failed with an unexpected error. Here is the traceback:
cannot remove local variables from FrameLocalsProxy
Traceback (most recent call last):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 666, in execute
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 734, in _run_jobs_serially
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 703, in _run_job
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/__init__.py", line 336, in __call__
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler
File "C:\Users\dpaladhi\.azure\cliextensions\vm-repair\azext_vm_repair\custom.py", line 1031, in repair_button
command = command_helper(logger, cmd, 'vm repair repair-button')
File "C:\Users\dpaladhi\.azure\cliextensions\vm-repair\azext_vm_repair\command_helper_class.py", line 40, in __init__
self.command_params = _get_function_param_dict(inspect.getouterframes(inspect.currentframe())[1].frame)
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\dpaladhi\.azure\cliextensions\vm-repair\azext_vm_repair\repair_utils.py", line 737, in _get_function_param_dict
del values['cmd']
~~~~~~^^^^^^^
ValueError: cannot remove local variables from FrameLocalsProxy

### Issue script & Debug output

PS C:\Users\dpaladhi> az vm repair repair-button --button-command 'fstab' --resource-group nobootscenariosrg --name fstabnoboot --debug cli.knack.cli: Command arguments: ['vm', 'repair', 'repair-button', '--button-command', 'fstab', '--resource-group', 'nobootscenariosrg', '--name', 'fstabnoboot', '--debug'] cli.knack.cli: __init__ debug log: Enable color in terminal. Enable VT mode. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'vm': ['azure.cli.command_modules.vm', 'azext_vm_repair'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: vm 4.180 60 280 cli.azure.cli.core: Total (1) 4.180 60 280 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: vm-repair 0.303 2 7 C:\Users\dpaladhi\.azure\cliextensions\vm-repair cli.azure.cli.core: Total (1) 0.303 2 7 cli.azure.cli.core: Loaded 61 groups, 287 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : vm repair repair-button cli.azure.cli.core: Command table: vm repair repair-button cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\dpaladhi\.azure\commands\2025-11-10.12-15-35.vm_repair_repair-button.47516.log'. az_command_data_logger: command args: vm repair repair-button --button-command {} --resource-group {} --name {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x0000023688CFE5C0>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x0000023688D5C900>, .add_cache_arguments at 0x0000023688D5CAE0>, .update_breaking_change_info at 0x0000023688D5CB80>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x0000023688D5C9A0>] az_command_data_logger: extension name: vm-repair az_command_data_logger: extension version: 2.1.2 This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus cli
... [truncated, original was 22208 chars]

## Comments
### Comment by @yonzhan

Thank you for opening this issue, we will look into it.

### Comment by @pagienge
This looks to be down to a change in the code calling the extensions, so the question probably needs to focus on azcli and find out if that was an intentional change.

It looks like the last az-cli code that calls the extension is this line (from the previous debug log):
File "D:\a\_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 120, in handler

When I look at the extension code I put in a debug line and see that in a working az-cli code base (2.71 for me), the extension is finding a dict type object but in a broken version it is instead 'FrameLocalsProxy', whatever that is. This is using the same extension code. This is the section of code that eventually parses the input and fails when it tries to delete an object from the input dict

def _get_function_param_dict(frame):
import inspect
from pprint import pprint
# getargvalues inadvertently marked as deprecated in Python 3.5
_, _, _, values = inspect.getargvalues(frame)
pprint(values.__class__)
pprint(values)
if 'cmd' in values:
del values['cmd']

### Comment by @pagienge
Image

Here's the code in a more 'readable' format. This is inside of the vm-repair extension. pprint lines are obviously my debug code

### Comment by @microsoft-github-policy-service[bot]
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Drewm3, @TravisCragg-MSFT, @nikhilpatel909, @sandeepraichura, @hilaryw29, @GabstaMSFT, @ramankumarlive, @ushnaarshadkhan.

### Comment by @yanzhudd
This command is owned and maintained by the service team.
Hi @EdwinBernal1, could you please help look into this issue, or direct it to the appropriate person?
Thanks!

### Comment by @yanzhudd
Azure CLI started supporting Python 3.13 beginning with version 2.77.0 (https://github.com/Azure/azure-cli/pull/31895).

This issue is likely related to changes introduced in Python 3.13 (see https://peps.python.org/pep-0667/). In Python 3.13 and later, the inspect.getargvalues() function can return a `FrameLocalsProxy` object as its locals component. The `FrameLocalsProxy` is an immutable, read-only mapping.
However, the existing logic in the `az vm repair` command is trying to remove a key from it.

A potential solution for resolving this issue is to create a new dict which does not contain the `cmd` item, instead of removing key `cmd` from the dict (https://github.com/Azure/azure-cli-extensions/blob/a74d9f4344b2bd2c069f09e345f2d7eb51ab9f0f/src/vm-repair/azext_vm_repair/repair_utils.py#L737):

''' python
# Create a new dict that does not contain the cmd dict item
if 'cmd' in values:
values = {key: val for key, val in values.items() if key != 'cmd'}
'''

Hi @EdwinBernal1
Since this module is owned and maintained by your team, could you please help by raising a PR to fix the issue? Thanks!
<<>>

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.