Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option "verbatim" in method species.name_usage throws error for specific taxon #109

Open
GrazingScientist opened this issue Feb 23, 2023 · 2 comments

Comments

@GrazingScientist
Copy link

Python Version: 3.8
pygbif Version: 0.6.2

When using the verbatim option in the species.name_usage method, I get an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/venv/lib/python3.8/site-packages/pygbif/species/name_usage.py", line 108, in name_usage
    return name_usage_fetch(data, key, shortname, uuid, args, **kwargs)
  File "/venv/lib/python3.8/site-packages/pygbif/species/name_usage.py", line 143, in name_usage_fetch
    res = gbif_GET(url, args, **kwargs)
  File "/venv/lib/python3.8/site-packages/pygbif/gbifutils.py", line 34, in gbif_GET
    out.raise_for_status()
  File "/venv/lib/python3.8/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.gbif.org/v1/species/5231190/verbatim?limit=100

Code to reproduce the error:

from pygbif import species
species.name_usage(key="5231190", data="verbatim")

However, when using the key for another taxon, it works:

from pygbif import species
species.name_usage(key="101683527", data="verbatim")

So, this issue seems to be on the API side. Still, this behavior is not documented.

@GrazingScientist
Copy link
Author

Since in Python, raising an exception is the most accepted way, I would suggest to throw a custom Exception that is more explanatory. When seeing the exception, I felt like I did something wrong.

@GrazingScientist GrazingScientist changed the title Option "verbatim" in method species.name_usage throws error for specieif taxon Option "verbatim" in method species.name_usage throws error for specific taxon Feb 23, 2023
@CecSve
Copy link
Contributor

CecSve commented Mar 17, 2023

Thank you for logging this issue and sorry for the late reply. You are right, we should include are custom exception explaining what the issues is in this case.

The issue is to do with the data itself. When you query a key in a checklist, then there is a verbatim value and the query is successful:
image

However, if you query a key from the GBIF taxonomic backbone (also technically a checklist, but the source GBIF use to interpret all the verbatim values we get from publishers), there is no verbatim value associated with the key (example below shows the backbone version of the same organism from the above example):
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants