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/+/64556 Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com> Reviewed-by: Sejal Sharma <sejalsharma@google.com>
diff --git a/hooks/install/sbom_info_lib/download_url.py b/hooks/install/sbom_info_lib/download_url.py index b35e99a..f6209e2 100644 --- a/hooks/install/sbom_info_lib/download_url.py +++ b/hooks/install/sbom_info_lib/download_url.py
@@ -142,7 +142,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