Bug 797971 - [REST API] Domain creation with duplicate name returns 409 with incorrect "messages" section
Summary: [REST API] Domain creation with duplicate name returns 409 with incorrect "me...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Pod
Version: 2.x
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: ---
Assignee: John (J5) Palmieri
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-27 16:52 UTC by Clayton Coleman
Modified: 2015-05-15 01:47 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-03-02 21:56:43 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Clayton Coleman 2012-02-27 16:52:47 UTC
Posting a domain name that already exists returns 409, but the "messages" array is not the same structure as other messages and so the site handling fails.  Should be consistent.  Needs to be fixed for sprint exit.

Started POST "/broker/rest/domains.json" for 127.0.0.1 at Mon Feb 27 11:32:12 -0500 2012
  Processing by DomainsController#create as JSON
  Parameters: {"namespace"=>"aoeu"}
Creating domain with namespace aoeu
MongoDataStore.find(CloudUser, test, test)


{\"status\":\"conflict\",\"messages\":[\"A namespace with name 'aoeu' already exists\"],\"version\":\"1.0\",\"data\":null,\"type\":null}"

Comment 1 John (J5) Palmieri 2012-02-28 00:43:05 UTC
I have a fix for this.  Testing it and going to commit it soon.

Comment 2 John (J5) Palmieri 2012-02-28 00:50:58 UTC
committed - issue was we have two code paths for validation errors and exceptions when saving out the namespace.  During namespace saving we now correctly use the Message object to set the error instead of just setting the error message.

I will write unit tests tomorrow and integrate this into the sauce tests I have been working on.

Comment 3 Meng Bo 2012-02-28 09:17:28 UTC
verified on devenv_1648, issue has been fixed.


Output:
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <version>1.0</version>
  <type nil="true"></type>
  <messages>
    <message>
      <field>namespace</field>
      <exit-code>103</exit-code>
      <severity>error</severity>
      <text>A namespace with name 'bmengdev5' already exists</text>
    </message>
  </messages>
  <status>conflict</status>
  <data nil="true"></data>
</response>

Comment 4 Lili Nader 2012-02-28 20:46:40 UTC
I also made changes to domain_controller.rb.  Now it returns

- 409 if the user already has a domain.  Only one domain per user is allowed today.

- 422 if the namespace is already in use.


Note You need to log in before you can comment on or make changes to this bug.