1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

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.
This commit is contained in:
Athanasius 2022-02-20 19:18:34 +00:00
parent e998d05d51
commit de69b95b8a
No known key found for this signature in database
GPG Key ID: AE3E527847057C7D

View File

@ -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