Police-Data-Accessibility-Project / data-sources-app

An API and UI for using and maintaining the Data Sources database
MIT License
2 stars 4 forks source link

Refactor `DataSourceByID` to not return 404 when a data source is not found #312

Open maxachis opened 1 month ago

maxachis commented 1 month ago

Currently, in the DataSourceByID class, the following code occurs when a data source is not found:

return {"message": "Data source not found."}, 404

404 is a status code typically use to indicate that a page on a web domain is not found -- not that a search does not pull the correct result. When I tested the GET method and got this result, I initially thought I'd done something wrong with my endpoint, and probably others would think this as well.

Recommend replacing this status code with something else -- possibly just 200, because it's not unexpected behavior if we can't find a data source using the GET method -- it may not exist in our database.