azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

[Bug] az devops invoke --area build contains two resources named "changes"

Open bryanbcook opened this issue 5 years ago • 3 comments

Describe the bug When I use az devops invoke for Builds - Get Build Changes it fails and prompts for parameters for Builds - Get Changes Between Builds

My investigation suggests there are 2 endpoints with the same area and resourceName.

az devops invoke --query "[?area=='build' && resourceName=='changes']"

produces the following:

[
  {
    "area": "build",
    "id": "f10f0ea5-18a1-43ec-a8fb-2042c7be9b43",
    "maxVersion": 6.0,
    "minVersion": 2.1,
    "releasedVersion": "0.0",
    "resourceName": "changes",
    "resourceVersion": 3,
    "routeTemplate": "{project}/_apis/{area}/{resource}"
  },
  {
    "area": "build",
    "id": "54572c7b-bbd3-45d4-80dc-28be08941620",
    "maxVersion": 6.0,
    "minVersion": 2.0,
    "releasedVersion": "5.1",
    "resourceName": "changes",
    "resourceVersion": 2,
    "routeTemplate": "{project}/_apis/{area}/builds/{buildId}/{resource}"
  }
]

To Reproduce Azure Cli Version: 2.7.0 Azure-Devops extension version: 0.18.0

Steps to reproduce the behavior:

  1. login using az login
  2. setup defaults for organization
  3. Run the following (with proper values for project and buildId)
az devops invoke --area build --resource changes --route-parameters project=myProject buildId=1234 --api-version 5.1-preview
  1. Fails with the following error: fromBuildId or toBuildId is null. Supply a valid value and try again.

The debug logs confirm that the 1st resource template is being used:

3108 : 2020-06-07 18:11:38,681 : DEBUG : azext_devops.devops_sdk.client : Route template: {project}/_apis/{area}/{resource}
3108 : 2020-06-07 18:11:38,682 : DEBUG : azext_devops.devops_sdk.client : Api version '5.1-preview'
3108 : 2020-06-07 18:11:38,683 : DEBUG : azext_devops.devops_sdk.client : GET https://dev.azure.com/my-org/my-projectname/_apis/build/changes

Expected behavior Given that there are two endpoints with the same area and resource, it appears to be using the first one instead of the second. Is there a way to provide more information to the command-line to ensure the 2nd one is used?

bryanbcook avatar Jun 07 '20 22:06 bryanbcook

As a suggestion, could the definition be changed to:

  {
    "area": "build",
    "id": "54572c7b-bbd3-45d4-80dc-28be08941620",
    "maxVersion": 6.0,
    "minVersion": 2.0,
    "releasedVersion": "5.1",
    "resourceName": "buildchanges",
    "resourceVersion": 2,
    "routeTemplate": "{project}/_apis/{area}/builds/{buildId}/changes"
  }

bryanbcook avatar Jun 07 '20 22:06 bryanbcook

Perhaps an alternative would allow the author to provide the --id instead of using area + resource?

  {
    "area": "build",
    "id": "54572c7b-bbd3-45d4-80dc-28be08941620",
    "maxVersion": 6.0,
    "minVersion": 2.0,
    "releasedVersion": "5.1",
    "resourceName": "changes",
    "resourceVersion": 2,
    "routeTemplate": "{project}/_apis/{area}/builds/{buildId}/{resource}"
  }
az devops invoke --id "54572c7b-bbd3-45d4-80dc-28be08941620" `
        --route-parameters `
                project=myProject `
                area=build `
                buildId=1234 `
                resource=changes `
         --api-version 5.1-preview

bryanbcook avatar Mar 06 '21 14:03 bryanbcook

Hi all, I can confirm the same bug in 7.2-preview version. Are there any solutions to switch between one or the other?

SAi-NetRom avatar Jan 29 '24 17:01 SAi-NetRom