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

`az repos pr show` not including tags/labels

Open celluj34 opened this issue 2 years ago • 18 comments

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command az repos pr show --id 2582 --detect true

Describe the bug Tags (or, as they are defined in the documentation, Labels) are not being returned in the above command. They are being returned from the REST api at .../_apis/git/repositories/<repository>/pullRequests/<pr id>/labels

To Reproduce

  1. Create a pull request in Azure DevOps
  2. Add a tag. The specific text doesn't matter.
  3. Run the above command to show the details

Expected behavior I expect the JSON response to contain any and all tags I've added to the PR.

Environment summary n/a

Additional context n/a

celluj34 avatar Aug 22 '22 19:08 celluj34

Thank you for your feedback. This has been routed to the support team for assistance.

ghost avatar Aug 22 '22 23:08 ghost

route to CXP team

yonzhan avatar Aug 22 '22 23:08 yonzhan

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @v-anvashist, @V-hmusukula.

Issue Details

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Related command az repos pr show --id 2582 --detect true

Describe the bug Tags (or, as they are defined in the documentation, Labels) are not being returned in the above command. They are being returned from the REST api at .../_apis/git/repositories/<repository>/pullRequests/<pr id>/labels

To Reproduce

  1. Create a pull request in Azure DevOps
  2. Add a tag. The specific text doesn't matter.
  3. Run the above command to show the details

Expected behavior I expect the JSON response to contain any and all tags I've added to the PR.

Environment summary n/a

Additional context n/a

Author: celluj34
Assignees: -
Labels:

Service Attention, customer-reported, DevOps

Milestone: -

ghost avatar Aug 23 '22 06:08 ghost

Adding Service attention label to devops issues.

@v-anvashist, @V-hmusukula. Could you please look into this and provide an update ?

navba-MSFT avatar Aug 23 '22 06:08 navba-MSFT

@celluj34 We are receiving the response from API so we have raised the issue to API team.

Once will get the update from them will share the updates on the same.

v-anvashist avatar Aug 29 '22 05:08 v-anvashist

@celluj34 we are following up with API team on this issue as we get the response from API. Once we receive the response from API team, we will share the updates.

v-soujanya avatar Sep 02 '22 04:09 v-soujanya

Great, thank you! Hopefully good news soon 🤞

celluj34 avatar Sep 02 '22 04:09 celluj34

@celluj34, we have not received response from API team yet and we are continuously following up with the team. we will share the updates once we receive from the API team.

v-soujanya avatar Sep 16 '22 12:09 v-soujanya

@celluj34 We have received response from API team and currently they have no plans enhancing the CLI to report the tags associated to the PR. They will consider this request if they have bandwidth. Thanks!

v-soujanya avatar Sep 26 '22 10:09 v-soujanya

Well, that's disappointing. Would the priority change if it were considered a bug instead of a feature? My reasoning would be since the call returns other information about the pull request (including nested details on the repository), not returning the tags is an "incomplete" response.

celluj34 avatar Sep 26 '22 18:09 celluj34

@celluj34 We will discuss with API team and get back to you.

v-anvashist avatar Sep 27 '22 04:09 v-anvashist

@celluj34 do we have any work item raised for this?

Arvindgade avatar Dec 21 '22 13:12 Arvindgade

@Arvindgade I am not sure what you mean - I don't work for Microsoft, I just use the cli.

celluj34 avatar Mar 24 '23 21:03 celluj34

@celluj34 We will discuss with API team and get back to you.

@v-anvashist Has there been discussion on this? I'm still interested in seeing this added.

celluj34 avatar Sep 18 '23 17:09 celluj34

I agree that this should be considered a bug. The field "labels" is there, so we are expecting this field to be properly initialized, but it's always empty.

killergege avatar Jan 05 '24 18:01 killergege

Hi @celluj34 We received response from API Team image

v-anvashist avatar Jan 11 '24 05:01 v-anvashist

It is interesting. From the API spec, there has a field "labels" but no value in the response. https://learn.microsoft.com/en-us/rest/api/azure/devops/git/pull-requests/get-pull-request-by-id?view=azure-devops-rest-7.1&tabs=HTTP#gitpullrequest

Even though the labels cannot be query in get-pull-request-by-id, the labels can be retrieved from the pull request labels API and aggregate it together in cli level. Why not go to this way?

hermanho avatar May 07 '24 18:05 hermanho

@hermanho Do you mean, why can't I combine the results from two queries? That's what I'm doing now, but I shouldn't have to. Using the az cli from Azure DevOps is much easier than hitting the rest api. And, as you've found, there is already the labels object but it's not populated. It should be returning the existing information.

Honestly, I don't understand why something like this requires years of deliberation. The rest api is returning this information, the cli has a placeholder for this information. Just... make them equal parity.

celluj34 avatar May 08 '24 02:05 celluj34

It's a bit funny that this is considered a feature. We get an incorrect value (null) for an existing property. :D

EDIT:

I figured out something, if you don't use az repos pr show --id ..., but az repos pr list -t <target_branch> -s <source_branch> --top 1 then it will send you back the tags correctly. 🤯 I guess this could be a workaround until we don't have this fixed on the show command. Because it's a list command it will return an array, I'm not sure if it has any limitations or caveats, but I think we can handle that (e.g. if we only need the labels then: --query [0].labels).

ducktordanny avatar Jul 10 '24 08:07 ducktordanny

@ducktordanny nice, thanks for the cli command! Here's the full command I got working:

az repos pr list -s <feature branch> -t master --top 1 --query "[].labels[?active].name | [0]"

returns you an output like so:

[
  "tag1",
  "tag2"
]

celluj34 avatar Jul 16 '24 13:07 celluj34

Cool, I've also written a post on Medium which is quite related, I'll leave it here, in case it can be a help to anyone: Stuck Azure pipeline cache.

ducktordanny avatar Jul 16 '24 14:07 ducktordanny