AtlassianPS / JiraPS

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

Improve error-handler to accommodate for ErrorDetails and non-JSON/HTML responses #277

Closed hmmwhatsthisdo closed 6 years ago

hmmwhatsthisdo commented 6 years ago

Description

This PR modifies Invoke-JiraMethod to improve error-parsing under certain conditions.

More specifically, the following changes have been made:

Motivation and Context

If Jira (or the web server/proxy used to access it) is using Chunked transfer encoding, for instance, this field may not be populated (see this PowerShell UserVoice post).

This PR resolves #276.

Types of changes

Checklist:

hmmwhatsthisdo commented 6 years ago

One of the things that may need additional refinement (probably in a separate PR) is how to handle non-JSON/HTML error responses.

For instance, this behemoth is spat out of the API if invalid credentials are passed to New-JiraSession. It seems to be a mixture of JavaScript and plain-text, which isn't a particularly easy thing to parse without resorting to regexes or something more hamfisted. Apparently this is/was due to Test-ServerResponse not being called appropriately following edge-case exception behavior during login.

hmmwhatsthisdo commented 6 years ago

@lipkau The New-JiraVersion integration tests appear to be 400ing - FWICT this can be caused by trying to create an issue where one with the same name already exists. Can you verify whether this is the case on the integration-test instance?