AtlasOfLivingAustralia/galah-python

Unhandled error when querying with unregistered email

roy-jingyang opened this issue · 1 comments

Hi team, thanks for the work. I'm just submitting an error message that I got when following the galah tutorial to make a query, but without having my email registered in prior.

It was a simple query for occurrences records:

galah.atlas_occurrences(
    taxa='Vulpes vulpes'
)

And below is the error message returned:

File ~\AppData\Local\anaconda3\envs\fc-sust\Lib\site-packages\galah\atlas_occurrences.py:292, in atlas_occurrences(taxa, filters, test, verbose, fields, assertions, use_data_profile, species_list, status_accepted)
    290         raise ValueError("It appears that you are not registered as a user on the Spanish atlas.  Please go to https://auth.gbif.es/cas/login?lang=en to register.")
    291 if atlas not in ["GBIF","Global"]:
--> 292     if response.json()['status'] == "skipped":
    293         raise ValueError(response.json()["error"])
    295 # this may take a while - occasionally check if status has changed

KeyError: 'status'

It should be easy to reproduce this error. galah-python==0.5.0

I had a quick look at the source code, and it appears that the error was thrown because the block designated for handling HTTP 403 was not effective: https://github.com/AtlasOfLivingAustralia/galah-python/blob/2fdfcfbd138f41b4b3bf471bdd60b8f796ec5409/galah/src/galah/atlas_occurrences.py#L280C1-L290

Maybe you want to update this according to the actual HTTP error returned? (I was not able to record it though)

It might also help to stress the need for email registration in the tutorial ;)

Cheers

Thanks @roy-jingyang for the feedback! I will update this pat of the code accordingly and it will be released in the next version :)