From 97fe435fc04b401eab197adcd15d212971ed6e0c Mon Sep 17 00:00:00 2001 From: Adriana Kobylak Date: Tue, 10 Apr 2018 10:44:11 -0500 Subject: rest_dbus: upload: Add version id error code If there was no D-Bus object created, it means that either the version already existed, or there was a failure extracting the file. Ideally the REST server would query to see if the version already exists, but it doesn't know the version id to look for, so adding a single error msg for all error cases. It still makes sense to have a 400 (client) error for tar errors since a failure to untar is most likely an invalid or corrupted file that the user would need to address. Tested: Uploading a regular file (that triggers a tar failure) or a version that already exists on the system: Before: { "data": null, "message": "200 OK", "status": "ok" } After: { "data": { "description": "Version already exists or failed to be extracted" }, "message": "400 Bad Request", "status": "error" } Fixes openbmc/openbmc#2939 Change-Id: Ia4be5fe1dac3c2c7ebb5eb2aa28e4d58f9222c7f Signed-off-by: Adriana Kobylak --- module/obmc/wsgi/apps/rest_dbus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/obmc/wsgi/apps/rest_dbus.py b/module/obmc/wsgi/apps/rest_dbus.py index 93cd4de..6374add 100644 --- a/module/obmc/wsgi/apps/rest_dbus.py +++ b/module/obmc/wsgi/apps/rest_dbus.py @@ -788,7 +788,10 @@ class ImageUploadUtils: break cls.signal.remove() cls.signal = None - return version_id + if version_id: + return version_id + else: + abort(400, "Version already exists or failed to be extracted") class ImagePostHandler(RouteHandler): -- cgit v1.2.1