sckott / habanero

client for Crossref search API
https://habanero.readthedocs.io
MIT License
202 stars 30 forks source link

habanero_utils.py gives TypeError on api.crossref.org 404 err #116

Closed joej closed 9 months ago

joej commented 1 year ago

I called habanero.Crossref.prefixes() or habanero.Crossref.prefixes( dois=['10.1529] ) ... doesn't matter, likely a "bad query" But the end result is that api.crossref.org gives a 404 w/error message that habanero_utils.py doesn't handle well.

File "./publisher_prefixes.py", line 98, in data = cr.prefixes(dois=[ '10.1529'] ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "venv/lib/python3.11/site-packages/habanero/crossref/crossref.py", line 608, in prefixes return request( ^^^^^^^^ File "venv/lib/python3.11/site-packages/habanero/request.py", line 84, in request raise RequestError(r.status_code, parse_json_err(r)) ^^^^^^^^^^^^^^^^^ File "venv/lib/python3.11/site-packages/habanero/habanero_utils.py", line 64, in parse_json_err return x.json()["message"][0]["message"] TypeError: string indices must be integers, not 'str'

sckott commented 1 year ago

thanks for the report! i'll have a look

sckott commented 1 year ago

forgot to mention issue

sckott commented 1 year ago

@joej error parsing is fixed, however, /prefixes route isn't supported anymore, so I made the ids parameter (i think you meant ids instead of dois above?) required so users shouldn't hit that specific error anymore because ids is required.

sckott commented 9 months ago

done