Bug 1466225

Summary: inconsistent response when deleting nonexistent VM snapshot using API
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Jillian Tullo <jtullo>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Kourim <mkourim>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.8.0CC: jhardy, jtullo, obarenbo, simaishi
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: rest:snapshot
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1478506 (view as bug list) Environment:
Last Closed: 2018-03-06 15:31:36 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: 1478506    

Description Martin Kourim 2017-06-29 09:43:11 UTC
Description of problem:
When deleting nonexistent snapshot using REST API using POST, the response is
{
    "success": false,
    "message": "No snapshots available for this VM"
}
and the HTTP status is 200 (success)

When deleting nonexistent snapshot using 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.0


How reproducible:
Very


Steps to Reproduce:
1.
POST https://10.8.197.241/api/vms/<id_of_existing_vm>/snapshots/2222
{"action": "delete"}
or
DELETE https://10.8.197.241/api/vms/<id_of_existing_vm>/snapshots/2222


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

Comment 2 Jillian Tullo 2017-06-30 18:55:22 UTC
PR: https://github.com/ManageIQ/manageiq/pull/15489

Comment 4 Martin Kourim 2017-10-24 09:10:14 UTC
Verified that deleting nonexistent snapshot using REST API results in ActiveRecord::RecordNotFound"