Bug 795558 - [REST API] 409 on key creation with duplicate content should set error on :content field
Summary: [REST API] 409 on key creation with duplicate content should set error on :co...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: Pod
Version: 2.x
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Lili Nader
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-20 21:54 UTC by Clayton Coleman
Modified: 2015-05-15 01:46 UTC (History)
4 users (show)

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


Attachments (Terms of Use)

Description Clayton Coleman 2012-02-20 21:54:55 UTC
When attempting to use the new rest API to create a new key with the same value as another key, the server returns 409.  When we implement the story for returning validation errors we need to ensure the server sets the error message on the "content" element so the UI can correctly convey the right message in this case, and on the "name" element when the name is in conflict.  Otherwise, the UI can't display the correct error.

Comment 1 Clayton Coleman 2012-02-20 22:01:50 UTC
The problem is more subtle.  The site needs to know specifically (programmatically) when the key is in conflict (when the key is 'domain') vs. when the content is in conflict.  So the error message returned by the server specifically for the 'key already exists' and 'content already exists' error states needs to contain two separate "code" attributes that allows the site to programmatically determine the difference.

Isolated when debugging bug 795538

Comment 2 Clayton Coleman 2012-02-20 22:02:29 UTC
That previous comment should read "when the key is 'default' the site will do something different if the key is in conflict".

Comment 3 Meng Bo 2012-02-23 06:36:08 UTC
Checked on devenv_1632, via web site.
Improper error message "You have already created a key with that name" displays when adding ssh key with same contents and different key name.

Comment 4 Johnny Liu 2012-02-27 03:01:07 UTC
Verified this bug with devenv_1642, and PASS.
exit-code, field and text elements is filled in the output of REST API.


$  curl -k -X POST -H 'Accept: application/xml' -H 'Content-type: application/json' -d '{'\''name'\'':'\''default'\'','\''type'\'':'\''ssh-rsa'\'','\''content'\'':blablablabla}' --user jialiu:xx https://ec2-50-16-44-115.compute-1.amazonaws.com/broker/rest/user/keys
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <type nil="true"></type>
  <messages>
    <message>
      <exit-code>120</exit-code>
      <field>name</field>
      <text>SSH key with name default already exists. Use a different name or delete conflicting key and retry.</text>
      <severity>error</severity>
    </message>
  </messages>
  <status>conflict</status>
  <version>1.0</version>
  <data nil="true"></data>
</response>

$  curl -k -X POST -H 'Accept: application/xml' -H 'Content-type: application/json' -d '{'\''name'\'':'\''mykey'\'','\''type'\'':'\''ssh-rsa'\'','\''content'\'':blablablabla}' --user jialiu:xx https://ec2-50-16-44-115.compute-1.amazonaws.com/broker/rest/user/keys
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <type nil="true"></type>
  <messages>
    <message>
      <exit-code>121</exit-code>
      <field>content</field>
      <text>Given public key is already in use. Use different key or delete conflicting key and retry.</text>
      <severity>error</severity>
    </message>
  </messages>
  <status>conflict</status>
  <version>1.0</version>
  <data nil="true"></data>
</response>


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