Problem
If a Version is exported from Aha to Jira using the integration, and a fix version with that same name already exists in Jira, Jira will response with HTTP status code 400, and a JSON payload:
{"errorMessages":[],"errors":{"name":"A version with this name already exists in this project."}}
However, Aha will show a message like the following in the log:
Sending change for AHATICKET-R-1 Aha Release Name: Unhandled error with invalid payload. BODY=Server returned HTTP response code: 400 for URL: https://JIRA_HOST/rest/api/2/version
So the user cannot understand what caused the problem, and the affected Version is not specified, either.
Suggestion
The log and the info tooltip should say that the Version could not be exported because a version with the same name already exists in the Jira project. It should also specify the affected version in the integration log. This lets the user find and remove the duplicated version.
Implementation
It seems like message in the ‘Server returned HTTP response code … for URL …’ is coming from a Java HttpURLConnection object; in our projects, we have found that when we get a status code of 400 or above with this object, the real payload goes to the error stream rather than the input stream.
So the payload can be read from the error stream of the HttpURLConnection, and then the caller can pass the correct error message back based on the message from Jira.