sbom: don't error out when HTTP request returns error Sometimes http request errors out without returning a return code, which is not expected and causes SBOM generation failure. We should treat the error same as target URI doesn't exist. BUG=b/323569827 TEST=presubmit RELESAE_NOTE=None Change-Id: Idb48d904f500ed5a059a71050406d73e5d75264b Reviewed-on: https://cos-review.googlesource.com/c/third_party/platform/crosutils/+/64613 Reviewed-by: Sejal Sharma <sejalsharma@google.com> Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
diff --git a/hooks/install/sbom_info_lib/download_url.py b/hooks/install/sbom_info_lib/download_url.py index cd97fd6..74ecce9 100644 --- a/hooks/install/sbom_info_lib/download_url.py +++ b/hooks/install/sbom_info_lib/download_url.py
@@ -143,7 +143,10 @@ def is_uri_valid(uri): if not uri.strip().startswith("http"): return False - request = requests.get(uri, stream=True) + try: + request = requests.get(uri, stream=True) + except: + return False if request.status_code == 200: return True return False