Skip to content

S3 CopyObject fails with version id #2103

Closed
@josuegomes

Description

@josuegomes

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

Activity

added
bugThis issue is a bug.
needs-triageThis issue or PR still needs to be triaged.
on Sep 21, 2022
josuegomes

josuegomes commented on Sep 21, 2022

@josuegomes
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

jmklix commented on Sep 22, 2022

@jmklix
Member

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

self-assigned this
on Sep 22, 2022
added
investigatingThis issue is being investigated and/or work is in progress to resolve the issue.
and removed
needs-triageThis issue or PR still needs to be triaged.
on Sep 22, 2022
added
pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.
and removed
investigatingThis issue is being investigated and/or work is in progress to resolve the issue.
on Sep 27, 2022
added
p2This is a standard priority issue
on Nov 4, 2022
jmklix

jmklix commented on Feb 6, 2024

@jmklix
Member

This is fixed with this PR: #2564

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.p2This is a standard priority issuepending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @josuegomes@jmklix

      Issue actions

        S3 CopyObject fails with version id · Issue #2103 · aws/aws-sdk-cpp