Bug #18892
closedAPI server gives incorrect type of error message
Description
Description of problem:
API sometimes gives Ruby error "undefined method `id' for nil:NilClass"
HTTP 500 error is more useful in this context.
Steps to Reproduce:
[root@rhel7-3-server ~]# curl H "Accept:application/json,version=2" -H "Content-Type:application/json" -X POST -u admin:password -k -d '{"architecture_id":"1","environment_name":"production", "domain_id":1, "mac":"00-00-5E-00-53-00", "location_id":1, "name":"test", "operatingsystem_id":"1","organization_id":"1" }' https://foreman.example.com/api/hosts | python -m json.tool:--:-- --:--:-- --:--:-- 1516
{
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 247 0 68 100 179 574 1513 -
"error": {
"message": "undefined method `id' for nil:NilClass"
}
}
Actual results:
"error": {
"message": "undefined method `id' for nil:NilClass"
Expected results:
HTTP 500 Internal Error