Azure / azure-cli

Azure Command-Line Interface
MIT License
3.96k stars 2.94k forks source link

`az repos pr show` not including tags/labels #23626

Open celluj34 opened 2 years ago

celluj34 commented 2 years ago

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

ghost commented 2 years ago

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

yonzhan commented 2 years ago

route to CXP team

ghost commented 2 years ago

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//pullRequests//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: -
navba-MSFT commented 2 years ago

Adding Service attention label to devops issues.

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

v-anvashist commented 2 years ago

@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-soujanya commented 2 years ago

@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.

celluj34 commented 2 years ago

Great, thank you! Hopefully good news soon 🤞

v-soujanya commented 1 year ago

@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 commented 1 year ago

@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!

celluj34 commented 1 year ago

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.

v-anvashist commented 1 year ago

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

Arvindgade commented 1 year ago

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

celluj34 commented 1 year ago

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

celluj34 commented 11 months ago

@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.

killergege commented 8 months ago

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.

v-anvashist commented 7 months ago

Hi @celluj34 We received response from API Team

image
hermanho commented 4 months ago

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?

celluj34 commented 4 months ago

@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.

ducktordanny commented 1 month ago

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

celluj34 commented 1 month ago

@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"
]
ducktordanny commented 1 month ago

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.