open-humans
open-humans copied to clipboard
API should return 400 error if attempting to delete file that doesn't exist
Our API endpoint for file deletion (/api/direct-sharing/project/files/delete/
) should return a 400 error if no files exist that can be deleted.
General Checkups
- [x] Have you checked that there isn't already an existing issue that describes what you report below?
- [x] Have you checked that there isn't already an open pull requests for this issue/update/change?
Description
Currently we have a server error when a project attempts to delete a file by file_id
, and that file no longer exists. See: https://github.com/OpenHumans/open-humans/blob/master/private_sharing/api_views.py#L332
This should be handled in the code and return a 400 error in the API, something like "No file found matching this ID."
Also, requests made by file_basename
should produce an error if no matching file exists.