Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error handling on upload #126

Merged
merged 2 commits into from
May 8, 2020
Merged

Improve error handling on upload #126

merged 2 commits into from
May 8, 2020

Conversation

trygve-lie
Copy link
Contributor

This improves error handling on multiple cases where an upload can cause an error. They are more or less as follow:

  • The arguments on each handler method is now the first thing to be validated. In other words we fail fast on wrong URI params.
  • If a filepath or mimetype does not validate when writing / reading / deleting a file, the validation will error and terminate the operation. This did not really work.
  • If a uploaded file is not a .tar or .tar.gz file, the upload process will be terminated with a http status 415. This status code have been in our API doc, but this has not really been the returned status code returned in this situation.
  • If a uploaded file is to large, the upload process will now be terminated with a http status 413. This is a new http status code not described in our API doc.
  • If a uploaded file is valid but is borked or contain a file we can not handle or parse for some reason, the upload process will now be terminated with a http status 422. This is a new http status code not described in our API doc.
  • There are also files which we are not able to detect the mime type of. These would previously not be given a mime type when written to a sink which causes some errors when serving it again. These are now given a default application/octet-stream mimetype.

This PR does also include the first proper tests of the handlers. Should pave the path to get these documented properly over time.

@trygve-lie trygve-lie requested a review from digitalsadhu May 7, 2020 17:05
Copy link
Member

@digitalsadhu digitalsadhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@trygve-lie trygve-lie merged commit 8eb52f6 into master May 8, 2020
@trygve-lie trygve-lie deleted the improve-upload branch May 8, 2020 06:55
@github-actions
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants