From 37159ae8bd2b6d7e91ebd7c4278ae02609907d4e Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Thu, 26 May 2022 19:14:29 +0000 Subject: [PATCH] Debian: Fix ugly error deleting a patch strategy A JSONDecodeError is raised when deleting a patch strategy that exists. (the error is not seen if no strategy exists) sw-manager patch-strategy delete Expecting value: line 1 column 1 (char 0) The issue is the JSON decoder does not handle an empty string. The empty string is a byte string on debian which runs on python3 so the comparison check needed to be updated. Test Plan: Verify that a patch strategy can be deleted on Debian without ugly messages. Verify that a non existant patch strategy can be deleted on Debian without ugly messages. Partial-Bug: 1974475 Signed-off-by: Al Bailey Change-Id: I18f84e20abf43a342e996c4752654bad3261e5a6 --- nfv/nfv-client/nfv_client/openstack/rest_api.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nfv/nfv-client/nfv_client/openstack/rest_api.py b/nfv/nfv-client/nfv_client/openstack/rest_api.py index 23544ce..785cd33 100755 --- a/nfv/nfv-client/nfv_client/openstack/rest_api.py +++ b/nfv/nfv-client/nfv_client/openstack/rest_api.py @@ -45,7 +45,9 @@ def request(token_id, method, api_cmd, api_cmd_headers=None, response_raw = url_request.read() - if response_raw == "": + # python2 the reponse may be an empty string + # python3 the response may be an empty byte string + if response_raw == "" or response_raw == b"": response = dict() else: response = json.loads(response_raw)