Repository navigation
Running az policy assignment list gives an IndexError #33786
Copy link
Copy link
Open
Labels
ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamThe command of the issue is owned by Azure CLI teambugThis issue requires a change to an existing behavior in the product in order to be resolved.This 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.Issues that are reported by GitHub users external to the Azure organization.
Milestone
Description
Describe the bug
When running the following command
az policy assignment list --scope <resource-group>I get the following output
/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/mgmt/resource/deploymentstacks/models/_models.py:119: SyntaxWarning: "\/" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\/"? A raw string is also an option.
following actions are automatically appended to 'excludedActions': '*\/read' and
The command failed with an unexpected error. Here is the traceback:
list index out of range
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
To check existing issues, please visit: https://github.com/Azure/azure-cli/issuesThis is on the latest version of azure-cli on Homebrew (2.88.0). I previously ran this command on 2.83.0 and got the same error, except without this part
/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/mgmt/resource/deploymentstacks/models/_models.py:119: SyntaxWarning: "\/" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\/"? A raw string is also an option.
following actions are automatically appended to 'excludedActions': '*\/read' andOnce I tried upgrading to 2.88.0 I started seeing it, which makes me think it's not related to the error and might just be another weird issue introduced in recent versions.
Related command
az policy assignment list --scope <resource-group>
Errors
/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/mgmt/resource/deploymentstacks/models/_models.py:119: SyntaxWarning: "\/" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\/"? A raw string is also an option.
following actions are automatically appended to 'excludedActions': '*\/read' and
The command failed with an unexpected error. Here is the traceback:
list index out of range
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
To check existing issues, please visit: https://github.com/Azure/azure-cli/issuesIssue script & Debug output
/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/mgmt/resource/deploymentstacks/models/_models.py:119: SyntaxWarning: "\/" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\/"? A raw string is also an option.
following actions are automatically appended to 'excludedActions': '*\/read' and
The command failed with an unexpected error. Here is the traceback:
list index out of range
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
tcheek ~/Documents/code $ az policy assignment list --scope <resource-group> --debug
cli.knack.cli: Command arguments: ['policy', 'assignment', 'list', '--scope', '<resource-group>', '--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 0x1082f4930>, <function OutputProducer.on_global_arguments at 0x108416c40>, <function CLIQuery.on_global_arguments at 0x10844d430>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Using packaged command index for profile 'latest'.
cli.azure.cli.core: Found installed extension 'logic' (azext_logic).
cli.azure.cli.core: Blending packaged core index with local extension index.
cli.azure.cli.core: Modules found from index for 'policy': ['azure.cli.command_modules.policyinsights', 'azure.cli.command_modules.resource']
cli.azure.cli.core: Loading command modules...
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: policyinsights 0.053 9 17
cli.azure.cli.core: resource 0.031 55 251
cli.azure.cli.core: Loaded command modules:
cli.azure.cli.core: Total (2) 0.085 64 268
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 63 groups, 268 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : policy assignment list
cli.azure.cli.core: Command table: policy assignment list
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x108634f60>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/REDACTED/.azure/commands/2026-07-24.10-03-25.policy_assignment_list.32945.log'.
az_command_data_logger: command args: policy assignment list --scope {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x1097362a0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x10986f3d0>, <function register_global_policy_argument.<locals>.add_global_policy_argument at 0x10986f480>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x10986f530>, <function register_upcoming_breaking_change_info.<locals>.update_breaking_change_info at 0x10986f5e0>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x108416cf0>, <function CLIQuery.handle_query_parameter at 0x10844d4e0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x10986f320>]
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
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: list index out of range
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
az_command_data_logger: list index out of range
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 802, in _run_job
result = list(result)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 87, in __next__
return next(self._page_iterator)
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_paging.py", line 43, in __next__
self._executor(self._next_link)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/core/aaz/_command.py", line 250, in executor_wrapper
executor()
~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 539, in _execute_operations
self.pre_operations()
~~~~~~~~~~~~~~~~~~~^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 535, in pre_operations
Common.ResolveScopeForList(self)
~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/homebrew/Cellar/azure-cli/2.88.0/libexec/lib/python3.14/site-packages/azure/cli/command_modules/resource/policy.py", line 164, in ResolveScopeForList
if scope_parts[1] == 'providers' and len(scope_parts) > 4:
~~~~~~~~~~~^^^
IndexError: list index out of range
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 0x108635220>]
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 1.659 seconds (init: 1.501, invoke: 0.158)
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 8432 in cache file under /Users/REDACTED/.azure/telemetry/20260724100326068
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/REDACTED/.azure /Users/REDACTED/.azure/telemetry/20260724100326068"
telemetry.process: Return from creating process 32949
telemetry.main: Finish creating telemetry upload process.Expected behavior
No error, returns all policy assignments for the given resource group
Environment Summary
azure-cli 2.88.0
core 2.88.0
telemetry 1.1.0
Extensions:
logic 1.1.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/REDACTED/.azure'
Extensions directory '/Users/REDACTED/.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
Reactions are currently unavailable
Metadata
Metadata
Labels
ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAuto assign by botAzure CLI TeamThe command of the issue is owned by Azure CLI teamThe command of the issue is owned by Azure CLI teambugThis issue requires a change to an existing behavior in the product in order to be resolved.This 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.Issues that are reported by GitHub users external to the Azure organization.
Activity
yonzhan commentedon Jul 24, 2026
Thank you for opening this issue, we will look into it.
x-engineering-agent commentedon Jul 24, 2026
Bug Analysis
az policy assignment list --scope <resource-group>raises an unhandledIndexError: list index out of rangeinazure/cli/command_modules/resource/policy.py, inResolveScopeForList:scope_partsis built by splitting the--scopevalue on/. When the scopeis a resource-group-level scope such as
/subscriptions/<sub>/resourceGroups/<rg>,scope_partsonly has 5 elements(after removing the leading empty string from the split, indices 0-3), so
scope_parts[1]is safe there, but other shorter/malformed scope strings (or ascope missing the leading slash) can produce a
scope_partslist with fewerthan 2 elements, causing
scope_parts[1]to raiseIndexErrorinstead of aclear
CLIError.Fix: guard the length check before indexing, e.g. verify
len(scope_parts) > 1(and ideally validate the overall scope format) beforeaccessing
scope_parts[1], and raise a user-friendlyInvalidArgumentValueErrorfor malformed scopes instead of letting an
IndexErrorpropagate.Repro (from the issue, azure-cli 2.88.0):
Full traceback in the issue shows the failure originates in
ResolveScopeForListinsideazure/cli/command_modules/resource/policy.py.Use this EXACT PR title:
[Resource] Fix #33786:az policy assignment list --scope: fix IndexError in ResolveScopeForList when scope has fewer than 5 segmentsPR 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):
Keep the backticks around the command and the
Fix #33786:prefix. You may only adjust the wording after the command (the final summary) if the fix changes; the[Resource]prefix, issue link, and backticked command must stay.Description — follow the PR template and fill in:
Fixes #33786.az ...command this affects.[Resource] `az <command>`: <note>.Posted by agent-assist (autonomous bug-fix pipeline).