Closed AlanMcBee closed 2 years ago
Just to make it clear that this isn't just a one-off:
I discovered this bug when executing a query that normally returns many items. It just happened to return exactly one this time.
@AlanMcBee I checked it yesterday and I can reproduce it. But not like you said with work items over 5000. This always comes up if you have an array of items where the count is a division of 200 and the remainder is 1.
This results in a case where the $beginRange = 0 and $endRange = 0, thus throwing the exception:
The line that can cause this is the following: https://github.com/MethodsAndPractices/vsteam/blob/e6cd718a9a41712b1d3384fc0d3354d80eeb82a4/Source/Public/Get-VSTeamWiql.ps1#L66
Unit tests need also be specified for this.
... But not like you said with work items over 5000.
That's not what I thought I was saying. That 5000 value was the ID of the single work item that should have been returned by the query. It could have been any ID. It would not have to be a query for a work item by its ID (like I used in the repro); it could also be, as you discovered and stated, any query that returns a count where the modulus 200 of the count is equal to 1 (which includes a query that has a count of 1). It has nothing to do with the value 5000.
Steps to reproduce
Using:
Expected behavior
$workItem populated with work item with ID of 5000
Actual behavior
ParameterBindingValidationException thrown:
Environment data
OS
Server