Skip to content

Uninformative error messages when invalid email address used #285

@mjwestgate

Description

@mjwestgate

If I put an invalid email into galah_config(), the query will run, but then return something uninformative like:

Error in `req_perform()`:
! Failed to perform HTTP request.
Caused by error in `curl::curl_fetch_memory()`:
! Timeout was reached [api.ala.org.au]:
Operation timed out after 20001 milliseconds with 0 bytes received
Run `rlang::last_trace()` to see where the error occurred.

or

Error in `req_perform()`:
! HTTP 400 Bad Request.
• OAuth error
• realm: authentication required

or

Calling the API failed for `atlas_occurrences`

One (fairly large) question is why the same code is returning multiple error messages. But the fundamental issue is that none of the error messages tell the user what to do. There is no way to check if a given email is in the ALA's systems as that would be generate security risks. So there are two somewhat sensible options here:

easy: check whether the supplied email is valid, probably using regex, and error when it's not. This is a slightly irritating problem (see R for data science, stack overflow) but possible.

hard interpret the http error code and return the correct message. This is trickier because it appears to not be returning the correct information in some cases; e.g. the first example above, where the query times out rather than return an informative message. Also tricky because httr2 converts these to errors by default, and we'd have to capture them to parse correctly. But potentially possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions