From f4da560d96a0d0aa1e614c2de7080419979ea439 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 3 Jun 2023 08:40:56 +0200 Subject: [PATCH] Continued: - check dictionary keys before using them, prevents KeyError being raised --- fetch_blocks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fetch_blocks.py b/fetch_blocks.py index 900f1c0..154bd97 100755 --- a/fetch_blocks.py +++ b/fetch_blocks.py @@ -57,6 +57,12 @@ for blocker, software, origin, nodeinfo_url in rows: if json is None: print("WARNING: Could not fetch nodeinfo from blocker:", blocker) continue + elif not "metadata" in json: + print(f"WARNING: json()={len(json)} does not have key 'metadata', blocker='{blocker}'") + continue + elif not "federation" in json["metadata"]: + print(f"WARNING: json()={len(json['metadata'])} does not have key 'federation', blocker='{blocker}'") + continue # DEBUG: print("DEBUG: Updating nodeinfo:", blocker) fba.update_last_nodeinfo(blocker) -- 2.39.5