From de69b95b8a90505a2a99fda716ae7e3f530d0c75 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 20 Feb 2022 19:18:34 +0000 Subject: [PATCH] EDDN: codexentry/1: Tighten up 'empty string' checks It turns out some of the other strings, that do not have minLength=1 in the schema, can be empty and that's OK. i.e. NearestDestination. So, let's only check for the actual minLength=1 things. Which is a few top-level key:values, and then the contents of the Traits array. --- plugins/eddn.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/eddn.py b/plugins/eddn.py index d5db6e8d..d82abc13 100644 --- a/plugins/eddn.py +++ b/plugins/eddn.py @@ -970,7 +970,9 @@ class EDDN: logger.warning(f'this.body_id was not set properly: "{this.body_id}" ({type(this.body_id)})') ####################################################################### - for k, v in entry.items(): + # Check just the top-level strings with minLength=1 in the schema + for k in ('System', 'Name', 'Region', 'Category', 'SubCategory'): + v = entry[k] if v is None or isinstance(v, str) and v == '': logger.warning(f'post-processing entry contains entry["{k}"] = {v} {(type(v))}') # We should drop this message and VERY LOUDLY inform the @@ -978,6 +980,13 @@ class EDDN: # raw Journal event that caused this. return 'CodexEntry had empty string, PLEASE ALERT THE EDMC DEVELOPERS' + # Also check traits + if 'Traits' in entry: + for v in entry['Traits']: + if v is None or isinstance(v, str) and v == '': + logger.warning(f'post-processing entry[\'Traits\'] contains {v} {(type(v))}\n{entry["Traits"]}\n') + return 'CodexEntry Trait had empty string, PLEASE ALERT THE EDMC DEVELOPERS' + msg = { '$schemaRef': f'https://eddn.edcd.io/schemas/codexentry/1{"/test" if is_beta else ""}', 'message': entry