Bug 1476869

Summary: inconsistent response when deleting nonexistent authentication using API
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Gregg Tanzillo <gtanzill>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: jhardy, obarenbo, simaishi, smallamp
Target Milestone: GAKeywords: TestOnly
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1511105 (view as bug list) Environment:
Last Closed: 2018-06-21 21:09:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1511105    

Description Martin Kourim 2017-07-31 16:30:37 UTC
Description of problem:
When deleting nonexistent /api/authentication/:id using POST, the response is
{
    "success": false,
    "message": "Couldn't find Authentication with 'id'=:id"
}
and the HTTP status is 200 (success)

When deleting nonexistent authentication using the DELETE HTTP method, the response is empty and and the HTTP status is 204 (success).

The responses are inconsistent with responses from other collections where the "ActiveRecord::RecordNotFound" error is returned and the HTTP status is 404 (not found).

E.g. deleting nonexistent VM:
{
    "error": {
        "kind": "not_found",
        "message": "Couldn't find Vm with 'id'=199999 ...",
        "klass": "ActiveRecord::RecordNotFound"
    }
}
HTTP status 404


Version-Release number of selected component (if applicable):
5.8.1.5


How reproducible:
very


Steps to Reproduce:
1.
POST https://<ip_address>/api/authentications/2222
{"action": "delete"}
or
DELETE https://<ip_address>/api/authentications/2222


Expected results:
"ActiveRecord::RecordNotFound", HTTP status 404

Comment 2 Jillian Tullo 2017-08-04 18:54:56 UTC
PR: https://github.com/ManageIQ/manageiq/pull/15736

Comment 3 Satoe Imaishi 2017-09-28 18:09:27 UTC
PR: https://github.com/ManageIQ/manageiq-api/pull/17

Comment 4 Martin Kourim 2017-10-20 11:48:11 UTC
The issues is resolved for DELETE method, but is still there for POST method:

POST https://<ip_address>/api/authentications/2222
{"action": "delete"}

Response:
{
    "success": false,
    "message": "Couldn't find Authentication with 'id'=2222"
}

Comment 6 CFME Bot 2017-11-08 05:49:49 UTC
New commit detected on ManageIQ/manageiq-api/master:
https://github.com/ManageIQ/manageiq-api/commit/7d229d32f63ca56e0f1d4bdd389aa67a62b37f59

commit 7d229d32f63ca56e0f1d4bdd389aa67a62b37f59
Author:     Jillian Tullo <jtullo>
AuthorDate: Tue Nov 7 10:42:27 2017 -0500
Commit:     Jillian Tullo <jtullo>
CommitDate: Tue Nov 7 10:42:27 2017 -0500

    Ensure delete_action_handler always raises a not found for single resources
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1476869

 app/controllers/api/base_controller/results.rb | 6 +++++-
 spec/requests/authentications_spec.rb          | 8 ++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)