Project

General

Profile

Actions

Bug #18892

closed

API server gives incorrect type of error message

Added by Ondřej Pražák over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

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
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 247 0 68 100 179 574 1513 -
:--:-- --:--:-- --:--:-- 1516 {
"error": {
"message": "undefined method `id' for nil:NilClass"
}
}

Actual results:

"error": {
"message": "undefined method `id' for nil:NilClass"

Expected results:

HTTP 500 Internal Error

Actions

Also available in: Atom PDF