Skip to content

Aws::S3::Errors::IncompleteBody when passing IO at non-zero position to put_object since 1.210.0 #3346

Description

@kylesnowschwartz

Describe the bug

Since aws-sdk-s3 1.210.0, passing a File/IO object to put_object that isn't at position 0 results in Aws::S3::Errors::IncompleteBody. The SDK uploads 0 bytes while Content-Length reflects the actual file size.

This is a regression - prior versions automatically rewound the IO before upload.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

file = Tempfile.new
file.puts("some data")
# file position is now at EOF
client.put_object(bucket: 'my-bucket', key: 'test.txt', body: file)
# Should upload "some data\n"

Current Behavior

S3 returns IncompleteBody: You did not provide the number of bytes specified by the Content-Length HTTP header

Root Cause

PR #3323 changed PutObject to use trailer checksums (unsignedPayload: true). The AwsChunkedTrailerDigestIO wrapper doesn't rewind the underlying IO on initialization, so if the IO is at EOF, it immediately emits a zero-length chunk + trailer.

Notably, header checksums DO rewind (see calculate_checksum lines 359-363), making this inconsistent.

Reproduction Steps

require 'aws-sdk-s3'
require 'tempfile'

client = Aws::S3::Client.new(region: 'us-east-1')

file = Tempfile.new(['test', '.txt'])
file.puts("hello world")
# Don't rewind - file position at EOF

client.put_object(
  bucket: 'your-bucket',
  key: 'test.txt', 
  body: file
)
# => Aws::S3::Errors::IncompleteBody

Possible Solution

Add @io.rewind in AwsChunkedTrailerDigestIO#initialize, consistent with the pattern in calculate_checksum.

Gem version

aws-sdk-s3 1.210.0+, aws-sdk-core 3.241.0+

Environment

Ruby 3.4, macOS/Linux

Activity

  1. richardwang1124 commented on Jan 15, 2026

    @richardwang1124
    Contributor

    Hey, thanks for opening an issue. We'll be taking a look.

  2. github-actions commented on Jan 16, 2026

    @github-actions

    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.

  3. richardwang1124 commented on Jan 16, 2026

    @richardwang1124
    Contributor

    Hey, the fix in core version 3.241.4 will go out with today's release. Please let me know if there's anything else I can help with!

  4. added
    bugThis issue is a bug.
    and removed
    investigatingIssue is being investigated
    on Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.potential-regressionMarking this issue as a potential regression to be checked by team member

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions