Skip to content

Commit

Permalink
handle metadata website down or returning invalid json (#612)
Browse files Browse the repository at this point in the history
* handle metadata website down or returning invalid json

* catch json exception explicitly
  • Loading branch information
nicolasochem authored Nov 29, 2023
1 parent 34e657d commit 69240ec
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/config-generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,13 @@ def create_node_snapshot_config_json(history_mode):
octez_container_version = os.environ.get("OCTEZ_VERSION")
snapshot_source = os.environ.get("SNAPSHOT_SOURCE")
if snapshot_source:
all_snapshots = requests.get(snapshot_source).json()
try:
response = requests.get(snapshot_source)
response.raise_for_status() # Raises an HTTPError if the HTTP request returned an unsuccessful status code
all_snapshots = response.json()
except (requests.exceptions.RequestException, requests.exceptions.JSONDecodeError): # Catches exceptions related to requests and invalid JSON
print(f"Error: unable to retrieve snapshot metadata from {snapshot_source}")
return
else:
return
try:
Expand Down

0 comments on commit 69240ec

Please sign in to comment.