Azure / azure-devops-cli-extension

Azure DevOps Extension for Azure CLI
https://docs.microsoft.com/en-us/cli/azure/ext/azure-devops/?view=azure-cli-latest
MIT License
632 stars 242 forks source link

[Bug] "IndexError: list index out of range" from `az pipelines list ...` #531

Closed jlucktay closed 5 years ago

jlucktay commented 5 years ago

Describe the bug Attempting to list releases in my client's Azure DevOps instance returned a Python IndexError.

To Reproduce Azure CLI version: azure-cli 2.0.62 Azure DevOps extension version: azure-devops 0.4.0

Steps:

  1. Install the Azure DevOps extension with az extension add --name azure-devops.
  2. Run az login and click through the browser window to a successful login.
  3. Run az pipelines release list --org <client org> --project <client project> --top 3 and receive the below error.

Expected behaviour A list of the 3 most recent releases from the nominated org & project should be shown.

Debug logs

DEBUG: Command arguments: ['pipelines', 'release', 'list', '--org', '<client org>', '--project', '<client project>', '--top', '3', '--debug']
DEBUG: Event: Cli.PreExecute []
DEBUG: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x102137268>, <function OutputProducer.on_global_arguments at 0x1021cd0d0>, <function CLIQuery.on_global_arguments at 0x1021e66a8>]
DEBUG: Event: CommandInvoker.OnPreCommandTableCreate []
DEBUG: Installed command modules ['acr', 'acs', 'advisor', 'ams', 'appservice', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'configure', 'consumption', 'container', 'cosmosdb', 'dla', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'interactive', 'iot', 'iotcentral', 'keyvault', 'kusto', 'lab', 'maps', 'monitor', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'reservations', 'resource', 'role', 'search', 'security', 'servicebus', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'vm']
DEBUG: Loaded module 'acr' in 0.004 seconds.
DEBUG: Loaded module 'acs' in 0.003 seconds.
DEBUG: Loaded module 'advisor' in 0.001 seconds.
DEBUG: Event: CommandLoader.OnLoadCommandTable []
DEBUG: Loaded module 'ams' in 0.004 seconds.
DEBUG: Loaded module 'appservice' in 0.015 seconds.
DEBUG: Loaded module 'backup' in 0.003 seconds.
DEBUG: Event: CommandLoader.OnLoadCommandTable []
DEBUG: Loaded module 'batch' in 0.007 seconds.
DEBUG: Loaded module 'batchai' in 0.002 seconds.
DEBUG: Loaded module 'billing' in 0.002 seconds.
DEBUG: Loaded module 'botservice' in 0.003 seconds.
DEBUG: Event: CommandLoader.OnLoadCommandTable []
DEBUG: Loaded module 'cdn' in 0.002 seconds.
DEBUG: Loaded module 'cloud' in 0.001 seconds.
DEBUG: Loaded module 'cognitiveservices' in 0.001 seconds.
DEBUG: Loaded module 'configure' in 0.001 seconds.
DEBUG: Loaded module 'consumption' in 0.002 seconds.
DEBUG: Loaded module 'container' in 0.002 seconds.
DEBUG: Loaded module 'cosmosdb' in 0.003 seconds.
DEBUG: Loaded module 'dla' in 0.003 seconds.
DEBUG: Loaded module 'dls' in 0.003 seconds.
DEBUG: Loaded module 'dms' in 0.002 seconds.
DEBUG: Loaded module 'eventgrid' in 0.002 seconds.
DEBUG: Loaded module 'eventhubs' in 0.002 seconds.
DEBUG: Loaded module 'extension' in 0.001 seconds.
DEBUG: Loaded module 'feedback' in 0.001 seconds.
DEBUG: Loaded module 'find' in 0.001 seconds.
DEBUG: Loaded module 'hdinsight' in 0.002 seconds.
DEBUG: Loaded module 'interactive' in 0.001 seconds.
DEBUG: Loaded module 'iot' in 0.003 seconds.
DEBUG: Loaded module 'iotcentral' in 0.001 seconds.
DEBUG: Loaded module 'keyvault' in 0.006 seconds.
DEBUG: Loaded module 'kusto' in 0.002 seconds.
DEBUG: Loaded module 'lab' in 0.003 seconds.
DEBUG: Loaded module 'maps' in 0.001 seconds.
DEBUG: Loaded module 'monitor' in 0.004 seconds.
DEBUG: Loaded module 'network' in 0.024 seconds.
DEBUG: Loaded module 'policyinsights' in 0.002 seconds.
DEBUG: Loaded module 'privatedns' in 0.003 seconds.
DEBUG: Loaded module 'profile' in 0.001 seconds.
DEBUG: Loaded module 'rdbms' in 0.005 seconds.
DEBUG: Loaded module 'redis' in 0.002 seconds.
DEBUG: Loaded module 'relay' in 0.005 seconds.
DEBUG: Loaded module 'reservations' in 0.001 seconds.
DEBUG: Loaded module 'resource' in 0.006 seconds.
DEBUG: Loaded module 'role' in 0.003 seconds.
DEBUG: Loaded module 'search' in 0.001 seconds.
DEBUG: Loaded module 'security' in 0.003 seconds.
DEBUG: Loaded module 'servicebus' in 0.003 seconds.
DEBUG: Loaded module 'servicefabric' in 0.001 seconds.
DEBUG: Loaded module 'signalr' in 0.001 seconds.
DEBUG: Loaded module 'sql' in 0.005 seconds.
DEBUG: Loaded module 'sqlvm' in 0.002 seconds.
DEBUG: Event: CommandLoader.OnLoadCommandTable []
DEBUG: Loaded module 'storage' in 0.025 seconds.
DEBUG: Loaded module 'vm' in 0.012 seconds.
DEBUG: Loaded all modules in 0.199 seconds. (note: there's always an overhead with the first module loaded)
DEBUG: Extensions directory: '/Users/jameslucktaylor/.azure/cliextensions'
DEBUG: Found 1 extensions: ['azure-devops']
DEBUG: Extensions directory: '/Users/jameslucktaylor/.azure/cliextensions'
DEBUG: Loaded extension 'azure-devops' in 0.018 seconds.
DEBUG: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x102269ae8>]
INFO: az_command_data_logger : command args: pipelines release list --org {} --project {} --top {} --debug
DEBUG: metadata file logging enabled - writing logs to '/Users/jameslucktaylor/.azure/commands'.
DEBUG: Event: CommandInvoker.OnPostCommandTableCreate [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x102287ae8>, <function register_ids_argument.<locals>.add_ids_arguments at 0x1022bf400>]
DEBUG: Event: CommandInvoker.OnCommandTableLoaded []
DEBUG: Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x1031de048>]
DEBUG: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x1021cd158>, <function CLIQuery.handle_query_parameter at 0x1021e6730>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x1022bf488>, <function handler at 0x1032c9510>, <function DevCommandsLoader.post_parse_args at 0x103a4c9d8>]
DEBUG: Extensions directory: '/Users/jameslucktaylor/.azure/cliextensions'
DEBUG: Extensions directory: '/Users/jameslucktaylor/.azure/cliextensions'
INFO: az_command_data_logger : extension name: azure-devops
INFO: az_command_data_logger : extension version: 0.4.0
DEBUG: handling generic error
ERROR: cli.azure.cli.core.util : The command failed with an unexpected error. Here is the traceback:

ERROR: The command failed with an unexpected error. Here is the traceback:

ERROR: cli.azure.cli.core.util : list index out of range
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 326, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 384, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 375, in _run_job
    cmd_copy.exception_handler(ex)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 22, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 354, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 145, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 451, in default_command_handler
    return op(**command_args)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/pipelines/release.py", line 101, in release_list
    client = get_release_client(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 150, in get_release_client
    connection = get_vss_connection(team_instance)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 32, in get_vss_connection
    credentials = _get_credentials(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 45, in _get_credentials
    if PAT_ENV_VARIABLE_NAME in os.environ or get_credential(organization) is not None:
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 17, in get_credential
    token = _get_credential(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 24, in _get_credential
    key = _get_service_name(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 76, in _get_service_name
    return 'azdevops-cli:' + normalize_url_for_key(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 85, in normalize_url_for_key
    organization_name = organization_name.split('/')[1]
IndexError: list index out of range
ERROR: list index out of range
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/knack/cli.py", line 206, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 326, in execute
    raise ex
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 384, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 375, in _run_job
    cmd_copy.exception_handler(ex)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 22, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/six.py", line 693, in reraise
    raise value
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 354, in _run_job
    result = cmd_copy(params)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 145, in __call__
    return self.handler(*args, **kwargs)
  File "/usr/local/Cellar/azure-cli/2.0.62/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 451, in default_command_handler
    return op(**command_args)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/pipelines/release.py", line 101, in release_list
    client = get_release_client(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 150, in get_release_client
    connection = get_vss_connection(team_instance)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 32, in get_vss_connection
    credentials = _get_credentials(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/services.py", line 45, in _get_credentials
    if PAT_ENV_VARIABLE_NAME in os.environ or get_credential(organization) is not None:
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 17, in get_credential
    token = _get_credential(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 24, in _get_credential
    key = _get_service_name(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 76, in _get_service_name
    return 'azdevops-cli:' + normalize_url_for_key(organization)
  File "/Users/jameslucktaylor/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 85, in normalize_url_for_key
    organization_name = organization_name.split('/')[1]
IndexError: list index out of range
WARNING: cli.azure.cli.core.util : 
To open an issue, please run: 'az feedback'
WARNING: 
To open an issue, please run: 'az feedback'
INFO: az_command_data_logger : exit code: 1
INFO: telemetry.save : Save telemetry record of length 2636 in cache
WARNING: telemetry.check : Negative: The /Users/jameslucktaylor/.azure/telemetry.txt was modified at 2019-04-12 10:18:56.036003, which in less than 600.000000 s
INFO: command ran in 0.289 seconds.

Environment Summary

Darwin-18.5.0-x86_64-i386-64bit
Python 3.7.3
Shell: bash

azure-cli                         2.0.62

Extensions:
azure-devops                       0.4.0

Python location '/usr/local/Cellar/azure-cli/2.0.62/libexec/bin/python'
Extensions directory '/Users/jameslucktaylor/.azure/cliextensions'

Python (Darwin) 3.7.3 (default, Mar 27 2019, 09:23:15) 
[Clang 10.0.1 (clang-1001.0.46.3)]

Additional Context

I have removed the names of my client's private org and project from the command arguments supplied above.

gauravsaralMs commented 5 years ago

This is dupe of https://github.com/Azure/azure-devops-cli-extension/issues/429

relevant stack trace showing the same File "/Users/jaraco/.azure/cliextensions/azure-devops/azext_devops/dev/common/_credentials.py", line 85, in normalize_url_for_key organization_name = organization_name.split('/')[1] IndexError: list index out of range

Closing this as duplicate. This is not fixed but the issue will be tracked using a single issue which will be https://github.com/Azure/azure-devops-cli-extension/issues/429

gauravsaralMs commented 5 years ago

Thanks for reporting this @jlucktay !!!