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

CopyObjectRequest wrong host URL #2822

Closed
FaZeRs opened this issue Jan 24, 2024 · 4 comments
Closed

CopyObjectRequest wrong host URL #2822

FaZeRs opened this issue Jan 24, 2024 · 4 comments
Labels
bug This issue is a bug. dependencies This issue is a problem in a dependency. p2 This is a standard priority issue

Comments

@FaZeRs
Copy link

FaZeRs commented Jan 24, 2024

Describe the bug

When I try to copy object from one folder to another in same bucket I get an error Invalid response status from request (aws-c-s3: AWS_ERROR_S3_INVALID_RESPONSE_STATUS). This happens only for CopyObject, for HeadObject, ListObjects, GetObject, PutObject everything is correct

Expected Behavior

Expected host URL should be s3.giraffe360-mimosa.com and file should be copied
from
/cold-data/projects/db9768d14f7c4055aa7518e42b633888/floorplan/roomsketcher/floorplan-ALL-final_1_0.svg
to
/cold-data/projects/db9768d14f7c4055aa7518e42b633888/floorplan/roomsketcher/final_backups/floorplan-ALL-final_1_0_2024-01-24_13-03-01.svg

Current Behavior

Based on logs I see it has wrong host URL

[INFO] 2024-01-24 11:03:01.675 AuthSigning [140735609304640] (id=0x7fff88004380) Signing successfully built canonical request for algorithm SigV4, with contents 
HEAD
/projects/db9768d14f7c4055aa7518e42b633888/floorplan/roomsketcher/floorplan-ALL-final_1_0.svg

host:cold-data.giraffe360-mimosa.com
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:20240124T110301Z

host;x-amz-content-sha256;x-amz-date
UNSIGNED-PAYLOAD

For other requests it is correct

[INFO] 2024-01-24 11:03:01.541 AuthSigning [140735592519232] (id=0x7fff840032d0) Signing successfully built canonical request for algorithm SigV4, with contents 
PUT
/cold-data/projects/db9768d14f7c4055aa7518e42b633888/floorplan/roomsketcher/geometry.json

content-length:4073
content-md5:rg4HTU7lw0cuZltmQKY+2g==
content-type:binary/octet-stream
host:s3.giraffe360-mimosa.com
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-date:20240124T110301Z

content-length;content-md5;content-type;host;x-amz-content-sha256;x-amz-date
UNSIGNED-PAYLOAD

cold-data is bucket name.

Reproduction Steps

Aws::Auth::AWSCredentials credentials(access_key, secret_key, session_token);

Aws::S3Crt::ClientConfiguration config;
config.endpointOverride = host_;
config.useVirtualAddressing = false;
config.verifySSL = false;
config.enableEndpointDiscovery = false;
config.enableHostPrefixInjection = false;
config.region = Aws::Region::US_EAST_1;
config.scheme = Aws::Http::Scheme::HTTPS;
config.disableMultiRegionAccessPoints = true;
config.disableS3ExpressAuth = true;
config.payloadSigningPolicy = Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never;
config.useUSEast1RegionalEndPointOption = Aws::S3Crt::US_EAST_1_REGIONAL_ENDPOINT_OPTION::LEGACY;
config.enableEndpointDiscovery = false;
config.enableHostPrefixInjection = false;
config.version = Aws::Http::Version::HTTP_VERSION_3;

std::unique_ptr<Aws::S3Crt::S3CrtClient> client = std::make_unique<Aws::S3Crt::S3CrtClient>(credentials, config);

Aws::S3Crt::Model::CopyObjectRequest request;
request.SetBucket(bucket);
request.SetKey(dst_path);
request.SetCopySource(bucket + "/" + src_path);
auto outcome = client->CopyObject(request);
if (!outcome.IsSuccess()) {
  std::cerr << "Failed to copy file " << src_path << " to " << dst_path
             << " in bucket: " " << bucket
             << " with error: " << outcome.GetError().GetMessage()
             << " and error code: " << outcome.GetError().GetExceptionName();
}

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.249

Compiler and Version used

gcc 13.1.0

Operating System and version

Ubuntu 22.04.3 LTS

@FaZeRs FaZeRs added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 24, 2024
@jmklix jmklix self-assigned this Jan 26, 2024
@jmklix
Copy link
Member

jmklix commented Jan 26, 2024

I can repro this with the sample code you gave. Looking into what might be causing this.

@jmklix jmklix added investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jan 26, 2024
@jmklix
Copy link
Member

jmklix commented Apr 5, 2024

This is a problem with aws-c-s3. Opening an issue on that repo to be tracked there: awslabs/aws-c-s3#424. Leaving this issue open for now, I will make sure to update here when that one gets closed

@jmklix jmklix added dependencies This issue is a problem in a dependency. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Apr 5, 2024
@jmklix jmklix removed their assignment Apr 5, 2024
@TingDaoK
Copy link

The CRT client has a very limited support for copy object. One of the limitation is it only supports virtual host addressing style, here

In your case, you override the host to s3.giraffe360-mimosa.com, which is not the virtual hosting for S3 bucket. So, it's not currently supported by CRT client and currently we don't have any plan to support it. You can create a feature request.

I'd recommend to use the regular C++ S3 client for copy object instead of CRT, since there won't be much benefits to use CRT to do copy object (No throughput improvement), since the work mostly done in the server side.

@jmklix jmklix closed this as completed Oct 14, 2024
Copy link

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. dependencies This issue is a problem in a dependency. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

3 participants