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 CopyObject fails with version id #2103

Closed
josuegomes opened this issue Sep 21, 2022 · 4 comments
Closed

S3 CopyObject fails with version id #2103

josuegomes opened this issue Sep 21, 2022 · 4 comments
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.

Comments

@josuegomes
Copy link

Describe the bug

Ubuntu 22.04, GCC 11.2, aws-sdk-cpp 1.9.22 (from vcpkg)

This code (excerpt);

Aws::S3::Model::CopyObjectRequest copyObjectRequest;

auto outcome = s3Client.CopyObject(copyObjectRequest
	.WithCopySource("558007041168/Wedding/lenovelle.jpg?versionId=zm1uOxum.DfrtaVE9opSLgR21orgDN0L")
	.WithBucket("558007041168")
	.WithKey("Wedding/lenovelle1.jpg"));

fails with exception NoSuchKey - The specified key does not exist

Log shows:

[DEBUG] 2022-09-21 19:44:41.290 AWSAuthV4Signer [139753200830464] Canonical Request String: PUT
/Wedding/lenovelle1.jpg

amz-sdk-invocation-id:04F1939E-F0A3-4FD6-BB21-433DB8DA03BA
amz-sdk-request:attempt=1
content-length:0
content-type:application/xml
host:558007041168.s3.eu-central-1.amazonaws.com
x-amz-api-version:2006-03-01
x-amz-content-sha256:UNSIGNED-PAYLOAD
x-amz-copy-source:558007041168/Wedding/lenovelle.jpg%3FversionId%3Dzm1uOxum.DfrtaVE9opSLgR21orgDN0L
x-amz-date:20220921T194441Z

Note how x-amz-copy-source was encoded.

Expected Behavior

No exception.

Current Behavior

Exception NoSuchKey - The specified key does not exist

From the logs:

<Error><Code>NoSuchKey</Code><Message>The specified key does not exist.</Message><Key>Wedding/lenovelle.jpg?versionId=zm1uOxum.DfrtaVE9opSLgR21orgDN0L</Key><RequestId>QG9XH4MMABAZ0858</RequestId><HostId>TXkprRHfwnOHZM3JonCZbOeoNe9WJM+5jAIXSiB1pD1CdCdHGrli3HTi/ZZVPlj+fjiOATeHkGA=</HostId></Error>

Reproduction Steps

#include <iostream>

#include <aws/core/Aws.h>
#include <aws/core/utils/logging/DefaultLogSystem.h>
#include <aws/core/utils/logging/AWSLogging.h>

#include <aws/s3/S3Client.h>
#include <aws/s3/model/CopyObjectRequest.h>

int main()
{
	Aws::SDKOptions options;
	Aws::InitAPI(options);
	{
		Aws::Utils::Logging::InitializeAWSLogging(
			Aws::MakeShared<Aws::Utils::Logging::DefaultLogSystem>("s3copy", Aws::Utils::Logging::LogLevel::Debug, "s3copy-"));

		Aws::Client::ClientConfiguration clientConfiguration;
		clientConfiguration.region = "eu-central-1";

		Aws::S3::S3Client s3Client(clientConfiguration);

		Aws::S3::Model::CopyObjectRequest copyObjectRequest;
		auto outcome = s3Client.CopyObject(copyObjectRequest
			.WithCopySource("558007041168/Wedding/lenovelle.jpg?versionId=zm1uOxum.DfrtaVE9opSLgR21orgDN0L")
			.WithBucket("558007041168")
			.WithKey("Wedding/lenovelle1.jpg"));

		if (outcome.IsSuccess()) {
			std::cout << "Copied\n";
		}
		else {
			std::cout << "CopyObject error: "
					  << outcome.GetError().GetExceptionName() << " - "
					  << outcome.GetError().GetMessage() << std::endl;
		}

		Aws::Utils::Logging::ShutdownAWSLogging();
	}
	Aws::ShutdownAPI(options);
	return 0;
}

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.9.22 (vcpkg)

Compiler and Version used

gcc 11.2

Operating System and version

Ubuntu 22.04

@josuegomes josuegomes added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Sep 21, 2022
@josuegomes
Copy link
Author

For reference the same request using AWS CLI:

aws s3api copy-object --debug --copy-source 558007041168/Wedding/lenovelle.jpg?versionId=zm1uOxum.DfrtaVE9opSLgR21orgDN0L --bucket 558007041168 --key Wedding/lenovelle1.jpg

Logs this:

2022-09-21 16:50:02,263 - MainThread - botocore.auth - DEBUG - CanonicalRequest:
PUT
/Wedding/lenovelle1.jpg

host:558007041168.s3.eu-central-1.amazonaws.com
x-amz-content-sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
x-amz-copy-source:558007041168/Wedding/lenovelle.jpg?versionId=zm1uOxum.DfrtaVE9opSLgR21orgDN0L
x-amz-date:20220921T195002Z

@jmklix
Copy link
Member

jmklix commented Sep 22, 2022

I'm getting the exact same error on Mac. Looking into the cause of this

@jmklix jmklix self-assigned this Sep 22, 2022
@jmklix jmklix added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 22, 2022
@jmklix jmklix mentioned this issue Sep 27, 2022
11 tasks
@jmklix jmklix added pending-release This issue will be fixed by an approved PR that hasn't been released yet. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Sep 27, 2022
@jmklix jmklix added the p2 This is a standard priority issue label Nov 4, 2022
@jmklix
Copy link
Member

jmklix commented Feb 6, 2024

This is fixed with this PR: #2564

@jmklix jmklix closed this as completed Feb 6, 2024
Copy link

github-actions bot commented Feb 6, 2024

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. p2 This is a standard priority issue pending-release This issue will be fixed by an approved PR that hasn't been released yet.
Projects
None yet
Development

No branches or pull requests

2 participants