Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gems/aws-sdk-s3/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Unreleased Changes
------------------

* Issue - Return the copy response from multipart `copy_to`/`copy_from` instead of `nil` on success.

1.232.0 (2026-09-11)
------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def copy(options = {}) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength

put_tags(tag_set, resp, options) if tag_set
put_annotations(annotations, resp, options) if annotations&.any?
resp
end

private
Expand Down
15 changes: 15 additions & 0 deletions gems/aws-sdk-s3/spec/object/multipart_copy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ def request_params(operation_name)
it 'raises an error on invalid targets' do
expect { object.copy_to(:target) }.to raise_error(ArgumentError)
end

it 'does not return nil when a single-shot copy succeeds' do
resp = object.copy_to('target-bucket/target-key')

expect(resp).not_to be_nil
end

it 'does not return nil when a multipart copy succeeds' do
client.stub_responses(:head_object, client.stub_data(:head_object, content_length: 50 * 1024 * 1024))
client.stub_responses(:create_multipart_upload, upload_id: 'upload-id')

resp = object.copy_to('target-bucket/target-key', multipart_copy: true)

expect(resp).not_to be_nil
end
end

describe '#copy_from' do
Expand Down
18 changes: 18 additions & 0 deletions gems/aws-sdk-s3/spec/object_multipart_copier_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ module S3
copier.copy(base_options)
end

it 'returns the complete multipart upload response' do
resp = copier.copy(base_options)

expect(resp).not_to be_nil
end

it 'respects min_part_size' do
small_copier = ObjectMultipartCopier.new(client: client, min_part_size: 10 * 1024 * 1024)

Expand Down Expand Up @@ -80,6 +86,12 @@ module S3
copier.copy(base_options.merge(tags_directive: 'COPY'))
end

it 'returns the copy response after applying tags' do
resp = copier.copy(base_options.merge(tags_directive: 'COPY'))

expect(resp).not_to be_nil
end

it 'overrides user-supplied tags' do
expect(client).to receive(:create_multipart_upload)
.with(hash_not_including(:tagging))
Expand Down Expand Up @@ -227,6 +239,12 @@ module S3
copier.copy(base_options.merge(annotations_directive: 'COPY'))
end

it 'returns the copy response after applying annotations' do
resp = copier.copy(base_options.merge(annotations_directive: 'COPY'))

expect(resp).not_to be_nil
end

it 'raises on partial failure when applying annotations' do
client.stub_responses(:put_object_annotation, [{}, 'ServiceError'])

Expand Down
Loading