MethodsAndPractices / vsteam

PowerShell module for accessing Azure DevOps Services and Azure DevOps Server (formerly VSTS or TFS)
https://methodsandpractices.github.io/vsteam-docs/
MIT License
445 stars 155 forks source link

Error running Add-VSTeamWorkItem in version 6.5.0 #345

Closed wybaugh closed 4 years ago

wybaugh commented 4 years ago

Hey guys,

I'm receiving the following error when attempting to create a PBI:

CreateAzureDevOpsTicket failed System.Management.Automation.ValidationMetadataException: The variable cannot be validated because the value $Product Backlog Item is not a valid value for the WorkItemType variable.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()

Steps to reproduce

Write-Host "Creating PBI"
$tfsWorkItem = Add-VSTeamWorkItem -ProjectName $adoProject -Title $kaceTicket.Title -Description $description -WorkItemType 'Product Backlog Item' -IterationPath $adoIterationPath -AdditionalFields $additionalFields

Expanded:

Add-VSTeamWorkItem -ProjectName "BI Team" -Title "Test - please don't delete" -Description "KACE Ticket Test" -WorkItemType "Product Backlog Item" -IterationPath "BI Team" -AdditionalFields
 System.Collections.DictionaryEntry System.Collections.DictionaryEntry System.Collections.DictionaryEntry

Expected behavior

This works under 6.4.6 with no error

Actual behavior

CreateAzureDevOpsTicket failed System.Management.Automation.ValidationMetadataException: The variable cannot be validated because the value $Product Backlog Item is not a valid value for the WorkItemType variable.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.LightLambda.RunVoid1[T0](T0 arg0)
   at System.Management.Automation.PSScriptCmdlet.RunClause(Action`1 clause, Object dollarUnderbar, Object inputToProcess)
   at System.Management.Automation.PSScriptCmdlet.DoProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()

Environment data

OS

Server


> Get-VSTeamAPIVersion

Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
Release                        5.1                                                                                                                                                                                                                               
Version                        VSTS                                                                                                                                                                                                                              
MemberEntitlementManagement    6.0-preview                                                                                                                                                                                                                       
TaskGroups                     6.0-preview                                                                                                                                                                                                                       
DistributedTask                6.0-preview                                                                                                                                                                                                                       
Core                           5.1                                                                                                                                                                                                                               
Packaging                      6.0-preview                                                                                                                                                                                                                       
VariableGroups                 5.1-preview.1                                                                                                                                                                                                                     
Build                          5.1                                                                                                                                                                                                                               
Git                            5.1                                                                                                                                                                                                                               
ServiceEndpoints               5.0-preview                                                                                                                                                                                                                       
ExtensionsManagement           6.0-preview                                                                                                                                                                                                                       
Graph                          6.0-preview                                                                                                                                                                                                                       
Policy                         5.1                                                                                                                                                                                                                               
Tfvc                           5.1                                                                                                                                                                                                                               
Processes                      6.0-preview      

<!-- provide the output of $PSVersionTable -->

```powershell
> $PSVersionTable

Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
PSVersion                      5.1.16299.1146                                                                                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                           
BuildVersion                   10.0.16299.1146                                                                                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                               
SerializationVersion           1.1.0.1        
SebastianSchuetze commented 4 years ago

I edited you post for the code. Could you please make sure that you use code markup for readability? Thanks!

Is the "Product Backlog Item" a custom work item type?

wybaugh commented 4 years ago

Hi Sebastian. I don't think it is a custom work item type. 'Product Backlog Item' is a tab complete parameter option of the workitem type in VSTeam.

DarqueWarrior commented 4 years ago

Testing now.

DarqueWarrior commented 4 years ago

I was able to duplicate. I will work on a fix now. Thanks for reporting this. I will also add some integration tests around this.

wybaugh commented 4 years ago

Awesome! Thank you and thank you for an awesome module!

DarqueWarrior commented 4 years ago

A work-around until I get this changed pushed is to not set the default project and just pass it in. There is a WorkItem Type Validator that is kicking when you have a default project.

DarqueWarrior commented 4 years ago

Fix will be in 6.5.1