biocore / biocore/microsetta-public-api
Add exception handlers for common API errors
- Dominant language
- Python
- Stars
- 2
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
The current way of sending errors through the API is a bit clunky, e.g.,
https://github.com/biocore/microsetta-public-api/blob/8c4fef0120b8edc8b079bb0d4958df09fd2a56e0/microsetta_public_api/api/taxonomy.py#L30-L32
Whereas, adding an exception handler to the Flask app can help facilitate raising an error in python, and having that be recognized by Flask, instead of having to be sent up through the call stack, which can get annoying and make code harder to refactor. Here is an example of the same call above, with an exception handler and `raise UnknownID` implicitly added:
https://github.com/gwarmstrong/microsetta-public-api/blob/9d3e3251a25be17456a250205e506ca0c1b76d53/microsetta_public_api/api/taxonomy.py#L30
See this branch for a full example of adding an exception handler and reworking `check_missing_ids` to raise an exception.
https://github.com/biocore/microsetta-public-api/compare/master...gwarmstrong:add-exception-handlers
Ideally we could invoke this pattern pretty much anywhere there is a 404.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with microsetta_public_api/api/taxonomy.py, the linked example branch, and the existing check_missing_ids flow. Compare how the Flask app handles the example 404 and identify other API paths where the same pattern is intended. Done means common 404 cases raise exceptions that Flask converts into the expected API errors without manual propagation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- flask, python
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100