Bug 1223067 - API name validation should fail gracefully
Summary: API name validation should fail gracefully
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Quickstart Cloud Installer
Classification: Red Hat
Component: Installation - RHCI
Version: 1.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ga
: 1.0
Assignee: David Davis
QA Contact: jcallaha
Dan Macpherson
URL:
Whiteboard:
Depends On:
Blocks: rhci-sprint-11
TreeView+ depends on / blocked
 
Reported: 2015-05-19 17:47 UTC by jcallaha
Modified: 2016-04-29 16:22 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-02 15:21:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description jcallaha 2015-05-19 17:47:35 UTC
Description of problem:
Providing 

Version-Release number of selected component (if applicable):
4/20/2015 ISO

How reproducible:
always

Steps to Reproduce:
1. Create a deployment
2. Send a PUT request to /fusor/api/v21/deployments/:id with a payload of {"name":5}
3. Observer returned results

Actual results:
{
    "displayMessage": "undefined method `strip' for 5:Fixnum",
    "errors": [
        "undefined method `strip' for 5:Fixnum"
    ]
}

Expected results:
A message should be returned that the name needs to be a valid string.

Additional info:
Any other passed non-string values return a generic error page
-----
We're sorry, but something went wrong.

We've been notified about this issue and we'll take a look at it shortly.

Comment 1 David Davis 2015-12-02 15:21:19 UTC
I tested this and it seems to work fine (see request below). Rails/ActiveRecord will support and store ints as strings but I imagine we were calling strip somewhere perhaps on the name field. I checked the code for calls to strip but found only two that were inside the undercloud controller. 

PUT /fusor/api/v21/deployments/1 HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Authorization: Basic YWRtaW46Y2hhbmdlbWU=
Connection: keep-alive
Content-Length: 11
Content-Type: application/json
Host: localhost
User-Agent: HTTPie/0.9.2

{
    "name": 5
}

HTTP/1.1 200 OK


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