Bug 797307

Summary: [REST API] Very long application name causes generic exception, not validation error
Product: OKD Reporter: Clayton Coleman <ccoleman>
Component: PodAssignee: Lili Nader <lnader>
Status: CLOSED CURRENTRELEASE QA Contact: libra bugs <libra-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.xCC: bmeng, mfisher, rmillner
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-02 21:56:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Clayton Coleman 2012-02-24 21:38:58 UTC
Creating an application with a name that is too long should fail with a standard validation error, not the generic error we get:

"Failed to create dns for application aoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeu due to:Error communicating with DNS system.  If the problem persists please contact Red Hat support."


Started POST "/broker/rest/domains/133011931617a395/applications.json" for 127.0.0.1 at Fri Feb 24 16:35:19 -0500 2012
  Processing by ApplicationsController#create as JSON
  Parameters: {"application_type"=>"raw-0.1", "cartridge"=>"raw-0.1", "domain_id"=>"133011931617a395", "name"=>"aoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeu"}

DEBUG: DYNECT put/post with path: /REST/CNAMERecord/rhcloud.com/aoeuaoeuaoe
uaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeuao
euaoeuaoeuaoeuaoeuaoeuaoeuaoeuaoeu-133011931617a395.dev.rhcloud.com/ json d
ata: {"ttl":"60","rdata":{"cname":"ec2-107-22-142-47.compute-1.amazonaws.co
m"}} and headers: {"Content-Type"=>"application/json", "Auth-Token"=>"c0lKi
HLerWsTvxkVteTrwGCzlpplBxk0+UX7EJIWAQbgvA0D5f2vSJq9LN3CHJ+xKu7/GNNTUR1pq27V
e7z+wqZI1Dsy4HQbwjPKEql8AWtdOpZhQSEchJ2BSOjRiw7i73LE/Eh70cROPaGtrO2DUMs3vPK
JVaGY"}
DEBUG: Response code: 400
DEBUG: Response body: {"status": "failure", "data": {}, "job_id": 68318246,
 "msgs": [{"INFO": "node: Invalid form", "SOURCE": "BLL", "ERR_CD": "INVALI
D_DATA", "LVL": "ERROR"}, {"INFO": "add_node: Could not add new zone node",
 "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}
DEBUG: Retrying dyn_put_post after exception caught from DNS request: Error
 communicating with DNS system.  If the problem persists please contact Red
 Hat support.

Comment 1 Rob Millner 2012-02-24 23:59:34 UTC
RFC 2181 restricts DNS names to no more than 255 characters, and no more than 63 characters per element.

Since we use the application name + domain as an element, that would place a very narrow restriction on the application name.

ex 
len("testapp-rmillner001") < 63
len("testapp-rmillner001.dev.rhcloud.com") < 255

Comment 2 Lili Nader 2012-02-27 20:09:49 UTC
Since we are limiting domain names to 16 chars that leaves 46 chars for app name.

Comment 3 Lili Nader 2012-02-28 21:57:47 UTC
According to the legacy code the max length for legacy code is 32 chars.

Comment 4 Meng Bo 2012-02-29 07:40:33 UTC
verified on devenv_1649, issue has been fixed.

Output:
<?xml version="1.0" encoding="UTF-8"?>
<response>
  <type nil="true"></type>
  <version>1.0</version>
  <messages>
    <message>
      <severity>error</severity>
      <exit-code>105</exit-code>
      <field>name</field>
      <text>The supplied application name 'myappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyappmyapp' is too long. (Max permitted length: 32 characters)</text>
    </message>
  </messages>
  <status>unprocessable_entity</status>
  <data nil="true"></data>
</response>