From 3e5056b02b22d9df43db0d95ecd770a360dcd357 Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Fri, 10 Jul 2020 22:47:02 +0200 Subject: datacite: mitigate sentry #44035 According to sentry, running `c.get('nameIdentifiers', []) or []` on a c with value: ``` {'affiliation': [], 'familyName': 'Guidon', 'givenName': 'Manuel', 'nameIdentifiers': {'nameIdentifier': 'https://orcid.org/0000-0003-3543-6683', 'nameIdentifierScheme': 'ORCID', 'schemeUri': 'https://orcid.org'}, 'nameType': 'Personal'} ``` results in a string, which I cannot reproduce. The document in question at: https://api.datacite.org/dois/10.26275/kuw1-fdls seems fine, too. --- python/fatcat_tools/importers/datacite.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/fatcat_tools/importers/datacite.py b/python/fatcat_tools/importers/datacite.py index f005f988..785107ee 100644 --- a/python/fatcat_tools/importers/datacite.py +++ b/python/fatcat_tools/importers/datacite.py @@ -732,6 +732,10 @@ class DataciteImporter(EntityImporter): if nameType in ('', 'Personal'): creator_id = None for nid in c.get('nameIdentifiers', []) or []: + if not isinstance(nid, dict): + # see: fatcat-workers/issues/44035/ + print('unexpected nameIdentifiers, expected list of dicts, got: {}'.format(nid), file=sys.stderr) + continue name_scheme = nid.get('nameIdentifierScheme', '') or '' if not name_scheme.lower() == "orcid": continue -- cgit v1.2.3