aws-s3 gem is so busted

I just spent an hour debugging some weird errors popping up with the aws/s3 gem, which seems to be quite buggy and under-maintained.

When attempting to delete an object, I kept getting one of these errors:
AWS::S3::MissingContentLength: You must provide the Content-Length HTTP header.

After trying a bunch of different monkey-patches, I settled on monkeypatching AWS::S3::Base::request, which seems to work –

module AWS
module S3
class Base
class << self
def request(verb, path, options = {}, body = nil, attempts = 0, &block)
Service.response = nil
process_options!(options, verb)
options['Content-Length'] ||= '0'
response = response_class.new(connection.request(verb, path, options, body, attempts, &block))
Service.response = response

Error::Response.new(response.response).error.raise if response.error?
response
# Once in a while, a request to S3 returns an internal error. A glitch in the matrix I presume. Since these
# errors are few and far between the request method will rescue InternalErrors the first three times they encouter them
# and will retry the request again. Most of the time the second attempt will work.
rescue *retry_exceptions
attempts == 3 ? raise : (attempts += 1; retry)
end
end
end
end
end

Ugly, but seems to work. No guarantees though. Has anyone else seen this?

Posted at 3pm on 5/16/08 | no comments | permalink

About

nothing much to say.

my latest photos