aws-sdk-ruby: Net::HTTP content-length Error When Yielding to Block
#<AWS::Core::Http::NetHttpHandler ::TruncatedBodyError: content-length does not match> /home/service/.rbenv/versio ns/1.9.3-p448/lib/ruby/gems/1.9.1/gems/aws-sdk-1.32.0/lib/aws/core/http/net_http _handler.rb:83:in `ensure in block (2 levels) in handle’
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 19 (10 by maintainers)
Commits related to this issue
- Fix Net::HTTP Handler Behavior There are two notable behavior changes: 1. We do not yield to a block when there is zero content. This was causing an exception upstream in the code (in the case of cli... — committed to aws/aws-sdk-ruby by awood45 10 years ago
- Tag release v1.43.2 References: #557, #563 — committed to aws/aws-sdk-ruby by trevorrowe 10 years ago
- Tag release v1.43.3 References: #557, #563 — committed to aws/aws-sdk-ruby by trevorrowe 10 years ago
- Tag release v1.44.0 References: #557, #563 — committed to aws/aws-sdk-ruby by trevorrowe 10 years ago
- Remove AWS credentials from final.yml — committed to cloudfoundry-community/tree-boshrelease by drnic 10 years ago
- update aws-sdk to fix issue with encrypted blobs AWS upgraded OpenSSL and introduced a regression for aws-sdk blobs using encryption. "These issues have existed in the code for some time, but negati... — committed to cloudfoundry/bosh by drnic 10 years ago
- upgrade aws-sdk gem to 1.52.0 we are seeing errors stream data from aws, when passing a block to read, which appears tomatches this bug: https://github.com/aws/aws-sdk-ruby/issues/557. at the time of... — committed to instructure/canvas-lms by simonista 10 years ago
- update aws-sdk to fix issue with encrypted blobs AWS upgraded OpenSSL and introduced a regression for aws-sdk blobs using encryption. "These issues have existed in the code for some time, but negati... — committed to cloudfoundry/bosh-aws-cpi-release by drnic 10 years ago
Some further info. The exception only happens if I write the
chunk
to the file. If I write something else, the exception does not occur:I added a counter to see how many chunks it processes:
In a completely un-scientific test of a “handful” of times, it always failed on the 8th chunk and always only wrote 34112 bytes, at least with my specific test file.
I suspected the presence of a
raise
inensure
block ofAWS::Core::Http::NetHttpHandler
is masking the original exception. Indeed, after modifying my local copy of the gem to preserve log this exception, I discovered that the origin is an encoding exception (at least in my case):#<Encoding::UndefinedConversionError: "\xCB" from ASCII-8BIT to UTF-8>
A cursory glance at the implementation in the latest version (well, master) implies that this issue is no longer present due to no longer using performing the length check in the context of an
ensure
clause.So, this probably is actually fixed. However, for people in older versions of the gem, perhaps ensure your file is open in binary mode first. This worked for me:
Alternatively, set the encoding to the chunk encoding: