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
633 stars 242 forks source link

az devops invoke --area wit --resource workitem cast error insted of returning workitem #1250

Open emilhvid opened 2 years ago

emilhvid commented 2 years ago

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az devops invoke Extension Name: azure-devops. Version: 0.23.0.

Errors:

The command failed with an unexpected error. Here is the traceback:
'type'
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 658, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 721, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 713, in _run_job
    return cmd_copy.exception_handler(ex)
  File "/home/vscode/.azure/cliextensions/azure-devops/azext_devops/dev/common/exception_handler.py", line 31, in azure_devops_exception_handler
    reraise(*sys.exc_info())
  File "/opt/az/lib/python3.6/site-packages/six.py", line 703, in reraise
    raise value
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 692, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
  File "/home/vscode/.azure/cliextensions/azure-devops/azext_devops/dev/team/invoke.py", line 108, in invoke
    content=request_body)
  File "/home/vscode/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 63, in _send
    query_parameters=query_parameters)
  File "/home/vscode/.azure/cliextensions/azure-devops/azext_devops/devops_sdk/client.py", line 116, in _create_request_message
    url = self._client.format_url(route_template, **route_values)
  File "/opt/az/lib/python3.6/site-packages/msrest/service_client.py", line 151, in format_url
    url = url.format(**kwargs)
KeyError: 'type'

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

Expected Behavior

Output a workitem

Environment Summary

Linux-5.10.60.1-microsoft-standard-WSL2-x86_64-with-debian-11.2, Debian GNU/Linux 11 (bullseye)
Python 3.6.10
Installer: DEB

azure-cli 2.32.0 *

Extensions:
azure-devops 0.23.0

Dependencies:
msal 1.16.0
azure-mgmt-resource 20.0.0

Additional Context

jeeger commented 1 week ago

I can reproduce with azure devops version 1.0.1. The problem might be that the resourceArea API query returns two templates for the invoke request:

    {
      "id": "72c7ddf8-2cdc-4f60-90cd-ab71c14a399b",
      "area": "wit",
      "resourceName": "workItems",
      "routeTemplate": "{project}/_apis/{area}/{resource}/{id}",
      "resourceVersion": 3,
      "minVersion": "1.0",
      "maxVersion": "7.2",
      "releasedVersion": "7.1"
    }
    {
      "id": "62d3d110-0047-428c-ad3c-4fe872c91c74",
      "area": "wit",
      "resourceName": "workItems",
      "routeTemplate": "{project}/_apis/{area}/{resource}/${type}",
      "resourceVersion": 3,
      "minVersion": "1.0",
      "maxVersion": "7.2",
      "releasedVersion": "7.1"
    },

There's probably an overlap with az devops trying to find the correct URL. az devops invoke --area wit --resource workItems --route-parameters type=1234 gives me a different error:

The controller for path '/_apis/wit/workItems/$1234' was not found or does not implement IController.  Operation returned a 404 status code.