jubos / fake-s3

A lightweight server clone of Amazon S3 that simulates most of the commands supported by S3 with minimal dependencies
2.94k stars 355 forks source link

[Feature] Multipart upload more descriptive error message for uploading one part #238

Open mrgcohen opened 6 years ago

mrgcohen commented 6 years ago

Love this library... great work!

Minor issue, but when submitting a part in a multipart upload the error is not very descriptive when using 0 as PartNumber. It took me a while to figure out that I was indexing with 0 instead of 1 PartNumber.

To Reproduce

  1. Create a multipart upload
  2. Submit a part with PartNumber 0

Result

This will succeed. It should give an error saying you can't upload a part with a PartNumber of 0.

Sample response from S3

Here's the response I get from S3.

<?xml version="1.0" encoding="UTF-8"?>
<Error>
    <Code>InvalidArgument</Code>
    <Message>Part number must be an integer between 1 and 10000, inclusive</Message>
    <ArgumentName>partNumber</ArgumentName>
    <ArgumentValue>0</ArgumentValue>
    <RequestId>[RequestIdHere]</RequestId>
    <HostId>[HostIdHere]</HostId>
</Error>
pickhardt commented 6 years ago

I'm leaning towards closing this as not a bug. It does say it should be between 1 and 10000 inclusive... which means 0 isn't included. I just double checked and S3's API has that exact wording: https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPart.html

"Part numbers can be any number from 1 to 10,000, inclusive. A part number uniquely identifies a part and also defines its position within the object being created. If you upload a new part using the same part number that was used with a previous part, the previously uploaded part is overwritten. Each part must be at least 5 MB in size, except the last part. There is no size limit on the last part of your multipart upload."

mrgcohen commented 6 years ago

I actually don't think it's a bug either cause I agree, it is a dumb error to make, but I'd imagine a common one.

It would be nice to just give a more descriptive error message.