Description
Python version: 3.10.9
habanero version: 1.2.2
Problem
My application fetches records by user-input DOIs, which sometimes are mistyped & not a valid DOI. Per the docs, warn=True
is the solution to ignore invalid DOIs and other error conditions. As expected, an invalid DOI will return a None
result; however, every id after it in the input list will also be None
(even if valid). Is this expected behavior?
Lines 158 to 159 in 183af9e
Example
from habanero import Crossref
cr = Crossref(mailto="...", ua_string="...")
bad_doi = '10.1200/jco.2021.39.15-suppl.e12560'
good_dois = ['10.1200/jco.2022.40.6_suppl.306', '10.1016/s1368-8375(21)00377-8', '10.1177/01945998211030908d', '10.1097/ju.0000000000000857.09']
responses = cr.works(ids=good_dois, warn=True)
len([r for r in responses if r])
# 4
responses = cr.works(ids=[bad_doi] + good_dois, warn=True)
len([r for r in responses if r])
# 0
My thoughts
This behavior seems unideal for all use cases. Either a caller wants an invalid DOI to fail the entire set of requests (which warn=False
already handles), or the caller wants to salvage as much data as possible, ignoring invalid results. By returning None
s with positional dependency, neither of these use cases are satisfied.
My expectation/preference would be for warn=True
to return None
for any id resulting in a non-200 query, and the standard response for any 200 query.