AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
321 stars 131 forks source link

Providing a transitionID as int via a variable fails in Invoke-JiraIssueTransition #415

Closed Rufus125 closed 4 years ago

Rufus125 commented 4 years ago

Description

I wanted to pass an integer to the Invoke-Transition call as parameter and wondered why it does not work via a variable.

$2ndLvlTransitionFromOpen = 1131
$transition = $newjraissue.Transition | where Name -eq "Fast 2nd level"
Invoke-JiraIssueTransition -Issue $newjraissue -Transition $transition #works
Invoke-JiraIssueTransition -Issue $newjraissue -Transition 1131 #works
Invoke-JiraIssueTransition -Issue $newjraissue -Transition $2ndLvlTransitionFromOpen #fails

Error message:

Invoke-JiraIssueTransition : Wrong object type provided for Transition. Expected [JiraPS.Transition] or [Int], but was String

Possible Solution

My guess is, that this has something to do with how an integer is treated (not as an Object). https://github.com/AtlassianPS/JiraPS/blob/master/JiraPS/Public/Invoke-JiraIssueTransition.ps1#L32 In this line the transition parameter is cast/set as an Object. This might be the problem. When I removed this line, the code above worked, but I did not create a pull request, since I am not sure if this would break something else.

Have a nice day :)

lipkau commented 4 years ago

Hi @Rufus125

Weird behavior. I tried ([Int]"$([Object][Int]1)").gettype() and it seems to work as the script expects it.

The script should be robust enough to not fail if you remove that line. So if you want, please create the PR.

With a next version of the module, I intend to have a object type [Transition]. So that behavior would be gone latest by then.