Skip to content

Running az policy assignment list gives an IndexError #33786

Open

Description

@Hoid

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/issues

This 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' and

Once 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/issues

Issue 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

Activity

  1. added
    bugThis issue requires a change to an existing behavior in the product in order to be resolved.
    on Jul 24, 2026
  2. added
    customer-reportedIssues that are reported by GitHub users external to the Azure organization.
    ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-group
    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 24, 2026
  3. yonzhan commented on Jul 24, 2026

    @yonzhan
    Collaborator

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

  4. x-engineering-agent commented on Jul 24, 2026

    @x-engineering-agent
    Contributor

    Bug Analysis

    az policy assignment list --scope <resource-group> raises an unhandled IndexError: list index out of range in
    azure/cli/command_modules/resource/policy.py, in ResolveScopeForList:

    if scope_parts[1] == 'providers' and len(scope_parts) > 4:

    scope_parts is built by splitting the --scope value on /. When the scope
    is a resource-group-level scope such as
    /subscriptions/<sub>/resourceGroups/<rg>, scope_parts only 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 a
    scope missing the leading slash) can produce a scope_parts list with fewer
    than 2 elements, causing scope_parts[1] to raise IndexError instead of a
    clear CLIError.

    Fix: guard the length check before indexing, e.g. verify
    len(scope_parts) > 1 (and ideally validate the overall scope format) before
    accessing scope_parts[1], and raise a user-friendly InvalidArgumentValueError
    for malformed scopes instead of letting an IndexError propagate.

    Repro (from the issue, azure-cli 2.88.0):

    az policy assignment list --scope <resource-group>
    

    Full traceback in the issue shows the failure originates in
    ResolveScopeForList inside azure/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 segments

    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):

    [Resource] Fix #33786: `az policy assignment list --scope <resource-group>`: fix IndexError in ResolveScopeForList when scope has fewer than 5 segments
    

    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:

    • Link the issue — start the Description with a closing keyword so the PR auto-links and closes it: Fixes #33786.
    • 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. [Resource] `az <command>`: <note>.
    • Keep the template checklist and tick the items you've satisfied.

    Posted by agent-assist (autonomous bug-fix pipeline).

  5. removed
    questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that
    on Jul 25, 2026
  6. added this to the Backlog milestone on Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

ARMaz resource/group/lock/tag/deployment/policy/managementapp/account management-groupAuto-AssignAuto assign by botAzure 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.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions