]> git.mxchange.org Git - fba.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Sat, 30 Sep 2023 21:54:51 +0000 (23:54 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 30 Sep 2023 21:54:51 +0000 (23:54 +0200)
- added some more checks to avoid exceptions

fba/networks/misskey.py

index b21db1ea524b282fce2e8e3e1cf498617f2089b1..7217b860db2c6f6b50c2310487374bc8ad351168 100644 (file)
@@ -199,10 +199,21 @@ def fetch_blocks(domain: str) -> list:
             for instance in rows:
                 # Is it there?
                 logger.debug("instance[]='%s'", type(instance))
+                if "host" not in instance:
+                    logger.warning("instance(%d)='%s' has no key 'host' - SKIPPED!", len(instance), instance)
+                    continue
+                elif instance["host"] is None or instance["host"] == "":
+                   logger.debug("instance[host]='%s' is None or empty - SKIPPED!", instance["host"])
+                   continue
+
+                logger.debug("instance[host]='%s' - BEFORE!", instance["host"])
                 blocked = tidyup.domain(instance["host"])
 
-                logger.debug("blocked='%s'", blocked)
-                if not domain_helper.is_wanted(blocked):
+                logger.debug("blocked[%s]='%s' - AFTER!", type(blocked), blocked)
+                if blocked is None or blocked == "":
+                    logger.warning("instance[host]='%s' is None or empty after tidyup.domain() - SKIPPED!", instance["host"])
+                    continue
+                elif not domain_helper.is_wanted(blocked):
                     logger.debug("blocked='%s' is not wanted - SKIPPED!", blocked)
                     continue
                 elif "isSuspended" in instance and instance["isSuspended"] and not dict_helper.has_key(blocklist, "blocked", blocked):