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

[Bug] - REST CopyObject, POSIX backend - attempt to add directory object w/same basename as non-dir obj results in confusing error. #1021

Open
lrm25 opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@lrm25
Copy link
Contributor

lrm25 commented Jan 9, 2025

Describe the bug
The error is:

<?xml version="1.0" encoding="UTF-8"?>
   <Error><Code>InvalidRequest</Code><Message>This copy request is illegal because it is trying to copy an object to itself without changing the object&#39;s metadata, storage class, website redirect location or encryption attributes.</Message><Resource></Resource><RequestId></RequestId><HostId></HostId></Error>

The error makes some sense, since trying to add a folder to another folder in POSIX, when a file with the same name already exists in that folder, results in a "file exists" error. However, this operation is legal in direct-to-s3, and may be confusing to someone coming from s3 who doesn't understand why this doesn't work with a POSIX backend. One suggestion is be similar to the s3api error response: "Directory object contains data payload", if the object contains data, or something similar to: "a directory object cannot have the same name as a non-directory object in POSIX mode."

To Reproduce

  1. Start versity with a posix backend, e.g.: ./versitygw --access=******** --secret=******** --region=us-east-1 --iam-dir=/Users/lukemccrone/devel/versitygw/iam --cert /Users/lukemccrone/devel/versitygw/cert.pem --key /Users/lukemccrone/devel/versitygw/versitygw.pem posix --versioning-dir /tmp/versioning /tmp/gw
  2. Create bucket, e.g.: aws --no-verify-ssl s3api create-bucket --bucket versity-gwtest-bucket-one-1
  3. Create, and add an object to the bucket, e.g.: aws --no-verify-ssl s3api put-object --body /Users/lukemccrone/devel/versitygw/versity-gwtest-files/a --bucket versity-gwtest-bucket-one-1 --key a
  4. Use to script at https://github.com/versity/versitygw/blob/test/directory_objects/tests/rest_scripts/copy_object.sh to send a command to copy 'a' to 'a/'. The curl command should look like this: curl -ks -w %{http_code} -X PUT https://localhost:7070/versity-gwtest-bucket-one-1/a/ -H Authorization: AWS4-HMAC-SHA256 Credential=********/20250109/us-east-1/s3/aws4_request,SignedHeaders=host;x-amz-content-sha256;x-amz-copy-source;x-amz-date,Signature=56ab338dbace53054d43c22a67837c861f9d3daa379dc71a2cc5b221570d0641 -H x-amz-content-sha256: UNSIGNED-PAYLOAD -H x-amz-copy-source: versity-gwtest-bucket-one-1/a -H x-amz-date: 20250109T215702Z -o /Users/lukemccrone/devel/versitygw/versity-gwtest-files/result.txt

Expected behavior
A clearer error when the copy fails.

Server Version
Version : v1.0.9
Build : 684d053
BuildTime: 2025-01-09_11:04:12PM
Darwin Lukes-MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:25 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6030 arm64

@lrm25 lrm25 added the bug Something isn't working label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant