open-humans icon indicating copy to clipboard operation
open-humans copied to clipboard

API should return 400 error if attempting to delete file that doesn't exist

Open madprime opened this issue 6 years ago • 0 comments

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.

madprime avatar Jan 28 '19 23:01 madprime