Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get-VSTeamWiql with (resultset.Count modulus 200) == 1 throws ParameterBindingValidationException #392

Closed
2 of 7 tasks
AlanMcBee opened this issue Apr 30, 2021 · 3 comments · Fixed by #406
Closed
2 of 7 tasks
Labels
bug when a bug has been identified or filed Investigating when an issue needs further investigation by a maintainer. Used only by maintainer.

Comments

@AlanMcBee
Copy link

Steps to reproduce

Using:

  • PS 7.1 (x64)
  • VSTeam 7.2.0
  • Azure DevOps Services Sprint 185+
  • established profile/connection to organization
# Change value of ID criteria as needed
$wiql = @'
SELECT
    [System.Id],
    [System.Title]
FROM workitems
WHERE
    [System.Id] = 5000
ORDER BY [System.Id]
'@

$workItem = Get-VSTeamWiql -Query $wiql -Expand

Expected behavior

$workItem populated with work item with ID of 5000

Actual behavior

ParameterBindingValidationException thrown:

Get-VSTeamWorkItem: C:\Program Files\WindowsPowerShell\Modules\VSTeam\7.2.0\vsteam.functions.ps1:5692
Line |
5692 |  …           Get-VSTeamWorkItem -Id $Ids[$beginRange..$endRange] -Fields …
     |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'Id' because it is null.

Environment data

OS

  • macOS
  • Windows
  • Linux

Server

  • TFS 2017
  • TFS 2018
  • Azure DevOps Server
  • Azure DevOps Service
> Get-VSTeamAPIVersion

Billing                     : 5.1-preview.1
Build                       : 5.1
Core                        : 5.1
DistributedTask             : 6.0-preview
DistributedTaskReleased     : 5.1
ExtensionsManagement        : 6.0-preview
Git                         : 5.1
Graph                       : 6.0-preview
HierarchyQuery              : 5.1-preview
MemberEntitlementManagement : 6.0-preview
Packaging                   : 6.0-preview
Pipelines                   : 5.1-preview
Policy                      : 5.1
Processes                   : 6.0-preview
Release                     : 5.1
ServiceEndpoints            : 5.0-preview
TaskGroups                  : 6.0-preview
Tfvc                        : 5.1
VariableGroups              : 5.1-preview.1
Version                     : VSTS
> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
@AlanMcBee
Copy link
Author

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.

@DarqueWarrior DarqueWarrior added the Investigating when an issue needs further investigation by a maintainer. Used only by maintainer. label May 17, 2021
@SebastianSchuetze
Copy link
Collaborator

SebastianSchuetze commented Jun 26, 2021

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

$endRange = [math]::Min(($beginRange + 199), ($countIds - 1))

Unit tests need also be specified for this.

@AlanMcBee
Copy link
Author

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

@AlanMcBee AlanMcBee changed the title Get-VSTeamWiql with 1 item in resultset throws ParameterBindingValidationException Get-VSTeamWiql with (resultset.Count modulus 200) == 1 throws ParameterBindingValidationException Jul 1, 2021
@SebastianSchuetze SebastianSchuetze added the bug when a bug has been identified or filed label Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug when a bug has been identified or filed Investigating when an issue needs further investigation by a maintainer. Used only by maintainer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants