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

S3 api CopyObject unexpected behavior if the source file does not exist #2306

Closed
aoberest opened this issue Sep 3, 2021 · 6 comments
Closed

Comments

@aoberest
Copy link

aoberest commented Sep 3, 2021

Hello

Describe the bug
S3 has a CopyObject command that lets you create a duplicate file.
Minio returns a 404 error if there is no source file, the target file is not created.
But, seaweedfs creates an empty target file

System Setup

  • OS version Centos 7
  • weed version
    version 30GB 2.65 cd838b1 linux amd64

Expected behavior
Returns a 404 error if there is no source file

Additional context
We are using AWS SDK for Java.
Sample code

final var request = CopyObjectRequest.builder()
            .sourceBucket("test")
            .sourceKey("asdasdsasdadas.pdf")
            .destinationBucket("test")
            .destinationKey("tedsa.pdf")
            .acl(PUBLIC_READ)
            .build();
        final var response = s3Client.copyObject(request);
@chrislusf
Copy link
Collaborator

Added a fix. But The return http status code is set to 400 (Bad Request). Please help to verify it.

@aoberest
Copy link
Author

aoberest commented Sep 6, 2021

@chrislusf Thanks for fast response.
But it doesn't work, I still get code 200

Response code: 200
ETag: d41d8cd98f00b204e9800998ecf8427e
lastModified: 2021-09-06T05:56:49.234483422Z
 final var copy = CopyObjectRequest.builder()
                .sourceBucket("test")
                .sourceKey(UUID.randomUUID() + ".pdf")
                .destinationBucket("test")
                .destinationKey("fg34.pdf")
                .acl(PUBLIC_READ)
                .build();
            final var copyResponse = s3Client.copyObject(copy);
            System.out.println("Response code: " + copyResponse.sdkHttpResponse().statusCode());
            System.out.println("ETag: " + copyResponse.copyObjectResult().eTag());
            System.out.println("lastModified: " + copyResponse.copyObjectResult().lastModified());

I think the absence of the file does not cause the error. Checking for missing file does not work.

@chrislusf
Copy link
Collaborator

chrislusf commented Sep 6, 2021

You are right.

Added f62df7f and 0cda61d to address this.

@aoberest
Copy link
Author

aoberest commented Sep 7, 2021

Hello @chrislusf
I found another problem in the 2.66 release. I think it is related to the recent change 491f763

I have 4 filer and the metadata is stored in Mysql Galera cluster. After updating to 2.66, I noticed that there are more tables in the database than before. The table names correspond to the files that were created when using the copyObject API. There is nothing inside the table.
See attachments.

I think the fix is f62df7f will close this problem

We need to release the next release as soon as possible.

Screenshot from 2021-09-07 10-00-47

Dbeaver

Screenshot from 2021-09-07 10-01-18

Screenshot from 2021-09-07 10-04-01

@aoberest
Copy link
Author

aoberest commented Sep 8, 2021

We have updated the version to 2.67 and have tested a CopyObject command

Answer:

software.amazon.awssdk.services.s3.model.S3Exception: Copy Source must mention the source bucket and key: sourcebucket/sourcekey. (Service: S3, Status Code: 400, Request ID: 1631075631955303645, Extended Request ID: null)

It seems to work correctly
thanks @chrislusf

@chrislusf
Copy link
Collaborator

Thanks for the update!

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

No branches or pull requests

2 participants