From 5ae953bf4559d86541e20fe3bd882eee15cfaae5 Mon Sep 17 00:00:00 2001
From: Athanasius <github@miggy.org>
Date: Sun, 17 Oct 2021 14:24:23 +0100
Subject: [PATCH] EDDN: Drop messages if EDDN says it doesn't know the schema

Currently Live EDDN doesn't yet have the new schemas such as navroute,
so will complain.  Rather than leaving such messages in our EDDN replay
queue and getting an error every time that is run, detect this error
case and drop the messages.
---
 plugins/eddn.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/plugins/eddn.py b/plugins/eddn.py
index 841cbead..9a783936 100644
--- a/plugins/eddn.py
+++ b/plugins/eddn.py
@@ -106,6 +106,11 @@ class EDDN:
     TIMEOUT = 10  # requests timeout
     MODULE_RE = re.compile(r'^Hpt_|^Int_|Armour_', re.IGNORECASE)
     CANONICALISE_RE = re.compile(r'\$(.+)_name;')
+    UNKNOWN_SCHEMA_RE = re.compile(
+        r"^FAIL: \[JsonValidationException\('Schema "
+        r"https://eddn.edcd.io/schemas/(?P<schema_name>.+)/(?P<schema_version>[0-9]+) is unknown, "
+        r"unable to validate.',\)\]$"
+    )
 
     def __init__(self, parent: tk.Tk):
         self.parent: tk.Tk = parent
@@ -210,6 +215,11 @@ class EDDN:
                 logger.trace_if('plugin.eddn', "EDDN is still objecting to empty commodities data")
                 return  # We want to silence warnings otherwise
 
+            if unknown_schema := self.UNKNOWN_SCHEMA_RE.match(r.text):
+                logger.warning(f"EDDN doesn't (yet?) know about schema: {unknown_schema['schema_name']}"
+                               f"/{unknown_schema['schema_version']}")
+                return  # Pretend it went OK so this message isn't retried
+
             logger.debug(
                 f'''Status from POST wasn't OK:
 Status\t{r.status_code}