From 0b3c297363626b0141afb1f3b74c337c632d46a4 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Mon, 2 Dec 2024 16:09:14 +0000 Subject: [PATCH] my_activity.py: Handle JSON parse errors Getting a lot of "(401) Unauthorized" responses for these now. This at least makes the script not crash. Change-Id: Ib42ccbdb3326a0918015e9d5e1cc9392a9c1a469 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6049877 Reviewed-by: Gavin Mak Commit-Queue: Andrew Grieve Auto-Submit: Andrew Grieve --- my_activity.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/my_activity.py b/my_activity.py index f2f8b0e123..d744cfc2bb 100755 --- a/my_activity.py +++ b/my_activity.py @@ -356,7 +356,10 @@ class MyActivity(object): url = url + '?' + query_data _, body = http.request(url) self.show_progress() - content = json.loads(body) + try: + content = json.loads(body) + except json.JSONDecodeError: + content = None if not content: logging.error('Unable to parse %s response from monorail.', project) return []