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

Misbehavior when cmdlet fails #302

Closed
lipkau opened this issue Jul 16, 2018 · 0 comments · Fixed by #303
Closed

Misbehavior when cmdlet fails #302

lipkau opened this issue Jul 16, 2018 · 0 comments · Fixed by #303

Comments

@lipkau
Copy link
Member

lipkau commented Jul 16, 2018

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

@lipkau lipkau self-assigned this Jul 16, 2018
@ghost ghost added the Status:In Review label Jul 16, 2018
lipkau added a commit that referenced this issue Jul 17, 2018
Fixed handling of server responses with an error
@ghost ghost removed the Status:In Review label Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant