sckott / habanero

client for Crossref search API

Home Page:https://habanero.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

joej opened this issue · comments

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'

thanks for the report! i'll have a look

forgot to mention issue

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