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

--query not working with azure devops work item fields

Open TopperKain opened this issue 4 years ago • 3 comments

Describe the bug

I am attempting to use a JMESPATH filter to bring back just the work item ids and work item titles related to a given Azure DevOps PR. I am able to get the work item ids, but not the title.

The query I am trying to run is [*].[id, fields."System.Title"] which, with the appropiate powershell escapes is:

[*].[id, fields.`"System.Title`"]

Note- if I do not provide a query parameter and save the results to a file ( az repos pr work-item list > myFile.json ) and then run a JMESPATH expression over that in visual studio, I get the expected results.

Command Name az repos pr work-item list Extension Name: azure-devops. Version: 0.12.0.

Errors: Does not return expected data

To Reproduce:

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

  • Put any pre-requisite steps here... Using powershell
$qry = "[*].[id, fields.`"System.Title`"]"
az repos pr work-item list --id 1 --query $qry

Expected Behavior

Returns both the id and title of work items from the pr identified.

[
  [
    3000,
    "My title 1"
  ],
  [
    4000,
    "My title 2"
  ]

Actual Behavior

Returns the id, but the title is null

[
  [
    3000,
    null
  ],
  [
    4000,
    null
  ]

Environment Summary

Windows-10-10.0.18362-SP0
Python 3.6.6
Shell: powershell.exe

azure-cli 2.0.67 *

Extensions:
azure-devops 0.12.0

Additional Context

TopperKain avatar Feb 12 '20 05:02 TopperKain

Hi @gauravsaralMs , could you please help with this devops issue ?

arrownj avatar Feb 13 '20 03:02 arrownj

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @narula0781, @ashishonce, @romil07.

ghost avatar May 26 '20 18:05 ghost

I found this bug item as I still faced the same issue. As a workaround (or maybe as expected behaviour) the back-ticks need to be escaped with a \ too.

So the following should work as expected:

$qry = "[*].[id, fields.\`"System.Title\`"]"
az repos pr work-item list --id 1 --query $qry

matt-tester avatar Jun 27 '22 01:06 matt-tester