From 529bfb432dd75011d6839e5e4e20954841a1993a Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Sat, 18 Mar 2023 03:59:21 -0400 Subject: [PATCH] Ignore errors loading artifacts from CircleCI Previously, this seemed to be ignored, and we'd just get a 0-artifact count. But now it seems that requesting artifacts for builds that are incomplete raises a 400 Bad Request. So ignore those errors and return a 0-length artifact, because that is already correctly handled by the next step in the workflow. --- .circleci/fetch_doc_logs.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/fetch_doc_logs.py b/.circleci/fetch_doc_logs.py index 40452cea7792..0a5552a7721c 100644 --- a/.circleci/fetch_doc_logs.py +++ b/.circleci/fetch_doc_logs.py @@ -22,7 +22,7 @@ from pathlib import Path import sys from urllib.parse import urlparse -from urllib.request import urlopen +from urllib.request import URLError, urlopen if len(sys.argv) != 2: @@ -38,8 +38,11 @@ f'{organization}/{repository}/{build_id}/artifacts' ) print(artifact_url) -with urlopen(artifact_url) as response: - artifacts = json.load(response) +try: + with urlopen(artifact_url) as response: + artifacts = json.load(response) +except URLError: + artifacts = {'items': []} artifact_count = len(artifacts['items']) print(f'Found {artifact_count} artifacts')