Hide Forgot
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.
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
That previous comment should read "when the key is 'default' the site will do something different if the key is in conflict".
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.
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>