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
Updated by Ondřej Pražák almost 8 years ago
- Subject changed from API server gives incorrect type of error message to API server gives incorrect type of error message
- Category changed from 19 to API
- Assignee set to Ondřej Pražák
Updated by The Foreman Bot almost 8 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/theforeman/foreman/pull/4373 added
Updated by Marek Hulán over 7 years ago
- Translation missing: en.field_release set to 240
Updated by Ondřej Pražák over 7 years ago
- Status changed from Ready For Testing to Closed
- % Done changed from 0 to 100
Applied in changeset f53bd4449d9eca64781fe9420de46eb4ec57139a.