Skip to content

Commit 849c917

Browse files
Fix query batch processing (#20345)
Co-authored-by: Wes Haggard <[email protected]>
1 parent 13908cf commit 849c917

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function Invoke-Query($fields, $wiql, $output = $true)
6262
-Uri "https://dev.azure.com/azure-sdk/Release/_apis/wit/wiql/?`$top=10000&api-version=6.0" `
6363
-Headers (Get-DevOpsRestHeaders) -Body $body -ContentType "application/json" | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
6464

65-
if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems")) {
65+
if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems") -or $response.workItems.Count -eq 0) {
6666
Write-Verbose "Query returned no items. $wiql"
6767
return ,@()
6868
}
@@ -83,11 +83,11 @@ function Invoke-Query($fields, $wiql, $output = $true)
8383
Write-Verbose "Pulling work items $uri "
8484

8585
$batchResponse = Invoke-RestMethod -Method GET -Uri $uri `
86-
-Headers $headers -ContentType "application/json" -MaximumRetryCount 3 | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
86+
-Headers (Get-DevOpsRestHeaders) -ContentType "application/json" -MaximumRetryCount 3 | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
8787

8888
if ($batchResponse.value)
8989
{
90-
$batchResponse.value | % { $workItems += $_ }
90+
$batchResponse.value | ForEach-Object { $workItems += $_ }
9191
}
9292
else
9393
{

0 commit comments

Comments
 (0)