Red Hat Bugzilla – Bug 1308563
Adding a host with a name that is already in use returns a Bad Request (code 400)
Last modified: 2016-07-05 03:52:27 EDT
Description of problem:
Adding a host with a name that is already in use returns a bad request (code 400), while doing the same with a Data Center returns a conflict (code 409).
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Add a host through the REST-API.
2. Add the same host again.
Bad request (code 400) with the message: "Cannot add Host. The Host name is already in use, please choose a unique name and try again."
We should get a conflict, not a bad request.
Adding a data center with a name that is already in use returns a conflict (code 409) with the message: "Cannot create Data Center. The Data Center name is already in use."
The API translates the error messages returned by the backend into HTTP codes according to the value returned by the ErrorMessage.getErrorType() message. The error returned by the backend when the name of the host is already in use is ACTION_TYPE_FAILED_NAME_ALREADY_USED, and the corresponding ErrorType is BAD_PARAMETERS, not CONFLICT. Not sure why it isn't CONFLICT. The change is simple, but it may have a backwards compatibility effect in existing clients, so I think it is better to not change it in the 3.6 branch.
Ori, do you know why this error type isn't classified as CONFLICT?
Moving from 4.0 alpha to 4.0 beta since 4.0 alpha has been already released and bug is not ON_QA.
Response: 409 Conflict: Cannot add Host. Host with the same address already exists.
oVirt 4.0.0 has been released, closing current release.