azure-cli
azure-cli copied to clipboard
`az repos pr show` not including tags/labels
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
- Create a pull request in Azure DevOps
- Add a tag. The specific text doesn't matter.
- 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
Thank you for your feedback. This has been routed to the support team for assistance.
route to CXP team
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
- Create a pull request in Azure DevOps
- Add a tag. The specific text doesn't matter.
- 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: |
|
Milestone: | - |
Adding Service attention label to devops issues.
@v-anvashist, @V-hmusukula. Could you please look into this and provide an update ?
@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.
@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.
Great, thank you! Hopefully good news soon 🤞
@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.
@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!
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 We will discuss with API team and get back to you.
@celluj34 do we have any work item raised for this?
@Arvindgade I am not sure what you mean - I don't work for Microsoft, I just use the cli.
@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.
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.
Hi @celluj34 We received response from API Team
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 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.
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 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"
]
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.