diff options
author | Adriana Kobylak <anoo@us.ibm.com> | 2018-04-10 10:44:11 -0500 |
---|---|---|
committer | Adriana Kobylak <anoo@us.ibm.com> | 2018-04-10 10:44:37 -0500 |
commit | 97fe435fc04b401eab197adcd15d212971ed6e0c (patch) | |
tree | b1bf4925ce1e82fbb6c5bce481a6beb5acc1fc0f /module | |
parent | 53693891092b5aa333caf636c91dd0c643153780 (diff) | |
download | phosphor-rest-server-97fe435fc04b401eab197adcd15d212971ed6e0c.tar.gz phosphor-rest-server-97fe435fc04b401eab197adcd15d212971ed6e0c.zip |
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 <anoo@us.ibm.com>
Diffstat (limited to 'module')
-rw-r--r-- | module/obmc/wsgi/apps/rest_dbus.py | 5 |
1 files changed, 4 insertions, 1 deletions
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): |