AtlassianPS / JiraPS

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

Misbehavior when cmdlet fails #302

Closed lipkau closed 6 years ago

lipkau commented 6 years ago

Description

When a command, such as New-JiraIssue fails (and the server returns an error message), two things are going wrong:

  1. the error is not printed (except when it is a string)
  2. a cmdlet, such as New-JiraIssue will try to use properties of an empty object

Steps To Reproduce

I ♥ PS> new-jiraissue -project HCC -IssueType Task -Summary "test" -Fields @{customfield_43300 = @{id = 77777}}
Get-JiraIssue : Cannot validate argument on parameter 'Key'. The argument is null or empty. Provide an argument that
is not null or empty, and then try the command again.
At C:\Users\Lipkau\Projects\jiraps\JiraPS\Public\New-JiraIssue.ps1:162 char:46
+             Write-Output (Get-JiraIssue -Key $result.Key -Credential  ...
+                                              ~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-JiraIssue], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Get-JiraIssue

Expected behavior

I ♥ PS▌new-jiraissue -project HCC -IssueType Task -Summary "test" -Fields @{customfield_43300 = @{id = 77777}}
Invoke-JiraMethod :
customfield_43300
-----------------
Field 'customfield_43300' cannot be set. It is not on the appropriate screen, or unknown.
At C:\Users\Lipkau\Projects\jiraps\JiraPS\Public\New-JiraIssue.ps1:157 char:27
+             if ($result = Invoke-JiraMethod @parameter) {
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
    + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod

Screenshots

image

Thanks to @thefonz for reporting this on slack