From b98737ffe35906449795cef248d3de9568b1bbe4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Sep 2026 18:49:35 +0530 Subject: [PATCH 1/2] Fix #227: properly display SW360Error details on 4xx/5xx by checking response is not None --- capycli/bom/check_bom.py | 4 ++-- capycli/project/create_project.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/capycli/bom/check_bom.py b/capycli/bom/check_bom.py index 3195b5ca..ba78f48b 100644 --- a/capycli/bom/check_bom.py +++ b/capycli/bom/check_bom.py @@ -66,7 +66,7 @@ def _find_by_id(self, component: Component) -> Optional[Dict[str, Any]]: print( " " + component.name + ", " + version + ", " + sw360id) - if swex.response: + if swex.response is not None: print(" Status Code: " + str(swex.response.status_code)) if swex.message: print(" Message: " + swex.message) @@ -105,7 +105,7 @@ def _find_by_name(self, component: Component) -> Optional[Dict[str, Any]]: print(Fore.LIGHTRED_EX + " Error retrieving release data: ") print( " " + component.name + ", " + version) - if swex.response: + if swex.response is not None: print(" Status Code: " + str(swex.response.status_code)) if swex.message: print(" Message: " + swex.message) diff --git a/capycli/project/create_project.py b/capycli/project/create_project.py index cff1b7f2..84db69c5 100644 --- a/capycli/project/create_project.py +++ b/capycli/project/create_project.py @@ -146,7 +146,7 @@ def update_project(self, project_id: str, project: Optional[Dict[str, Any]], if swex.response.status_code == requests.codes["forbidden"]: print_red(" You are not authorized - do you have a valid write token?") sys.exit(ResultCode.RESULT_AUTH_ERROR) - if swex.response: + if swex.response is not None: print_red(" " + str(swex.response.status_code) + ": " + swex.response.text) sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360) if swex.details: From 8e34cbcc6b046e02e91627599f8c22512b93363f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Sep 2026 00:17:37 +0530 Subject: [PATCH 2/2] Fix unreachable code in mypy check --- capycli/project/create_project.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/capycli/project/create_project.py b/capycli/project/create_project.py index 84db69c5..7920790f 100644 --- a/capycli/project/create_project.py +++ b/capycli/project/create_project.py @@ -146,12 +146,12 @@ def update_project(self, project_id: str, project: Optional[Dict[str, Any]], if swex.response.status_code == requests.codes["forbidden"]: print_red(" You are not authorized - do you have a valid write token?") sys.exit(ResultCode.RESULT_AUTH_ERROR) - if swex.response is not None: - print_red(" " + str(swex.response.status_code) + ": " + swex.response.text) - sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360) if swex.details: print_red(" " + swex.details.get("error", "") + ": " + swex.details.get("message", "")) sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360) + if swex.response.text: + print_red(" " + str(swex.response.status_code) + ": " + swex.response.text) + sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360) print_red(" Unknown error updating project: " + repr(swex)) sys.exit(ResultCode.RESULT_ERROR_ACCESSING_SW360)