Bug 1476869 - inconsistent response when deleting nonexistent authentication using API
Summary: inconsistent response when deleting nonexistent authentication using API
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: API
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.10.0
Assignee: Gregg Tanzillo
QA Contact: Martin Kourim
URL:
Whiteboard: api:rest
Depends On:
Blocks: 1511105
TreeView+ depends on / blocked
 
Reported: 2017-07-31 16:30 UTC by Martin Kourim
Modified: 2018-06-21 21:09 UTC (History)
4 users (show)

Fixed In Version: 5.10.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1511105 (view as bug list)
Environment:
Last Closed: 2018-06-21 21:09:59 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

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(-)


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