From: Thanh Ha Date: Fri, 29 Mar 2019 15:21:23 +0000 (-0400) Subject: Fix AttributeError on HTTPError in deploy code X-Git-Tag: v0.22.2~3 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F15123%2F2;p=releng%2Flftools.git Fix AttributeError on HTTPError in deploy code When a deploy nexus-zip fails it throws a stack trace with: AttributeError: 'HTTPError' object has no attribute 'value' Which is a very unhelpful error message but it's caused by the error handler code incorrectly handling the returned string value for the exception. Change-Id: I6d059dd73a5e774c15ab90a3b53728d6e051bf0c Signed-off-by: Thanh Ha --- diff --git a/lftools/deploy.py b/lftools/deploy.py index 51bba1b9..094119ad 100644 --- a/lftools/deploy.py +++ b/lftools/deploy.py @@ -359,7 +359,7 @@ def deploy_nexus_zip(nexus_url, nexus_repo, nexus_path, zip_file): log.info("Uploading {} failed. It contained the following files".format(zip_file)) for f in files: log.info(" {}".format(f)) - raise requests.HTTPError(e.value) + raise requests.HTTPError(e) log.debug('{}: {}'.format(resp.status_code, resp.text)) diff --git a/releasenotes/notes/fix-httperror-exception-6017608b5f939733.yaml b/releasenotes/notes/fix-httperror-exception-6017608b5f939733.yaml new file mode 100644 index 00000000..b819fc19 --- /dev/null +++ b/releasenotes/notes/fix-httperror-exception-6017608b5f939733.yaml @@ -0,0 +1,40 @@ +--- +fixes: + - | + Fix the unhelpful stack trace when a deploy nexus-zip fails to upload. + + .. code-block:: bash + + Traceback (most recent call last): + File "/home/jenkins/.local/bin/lftools", line 10, in + sys.exit(main()) + File "/home/jenkins/.local/lib/python2.7/site-packages/lftools/cli/__init__.py", line 110, in main + cli(obj={}) + File "/usr/lib/python2.7/site-packages/click/core.py", line 721, in __call__ + return self.main(*args, **kwargs) + File "/usr/lib/python2.7/site-packages/click/core.py", line 696, in main + rv = self.invoke(ctx) + File "/usr/lib/python2.7/site-packages/click/core.py", line 1065, in invoke + return _process_result(sub_ctx.command.invoke(sub_ctx)) + File "/usr/lib/python2.7/site-packages/click/core.py", line 1065, in invoke + return _process_result(sub_ctx.command.invoke(sub_ctx)) + File "/usr/lib/python2.7/site-packages/click/core.py", line 894, in invoke + return ctx.invoke(self.callback, **ctx.params) + File "/usr/lib/python2.7/site-packages/click/core.py", line 534, in invoke + return callback(*args, **kwargs) + File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func + return f(get_current_context(), *args, **kwargs) + File "/home/jenkins/.local/lib/python2.7/site-packages/lftools/cli/deploy.py", line 63, in archives + deploy_sys.deploy_archives(nexus_url, nexus_path, workspace, pattern) + File "/home/jenkins/.local/lib/python2.7/site-packages/lftools/deploy.py", line 236, in deploy_archives + deploy_nexus_zip(nexus_url, 'logs', nexus_path, archives_zip) + File "/home/jenkins/.local/lib/python2.7/site-packages/lftools/deploy.py", line 362, in deploy_nexus_zip + raise requests.HTTPError(e.value) + AttributeError: 'HTTPError' object has no attribute 'value' + + + Now instead it returns a much more helpful error message:: + + ERROR: Failed to upload to Nexus with status code: 401. + + test.zip