LoginSignup
1
1

More than 5 years have passed since last update.

Rubyのaws-sdkでDynamoDBにバイナリデータ(StringIO)を登録するとエラーが発生

Posted at

概要

Rubyのaws-sdkでDynamoDBにバイナリデータ(StringIO)を登録するとエラーが発生する。

再現

require 'aws-sdk'
client = Aws::DynamoDB::Client.new(region: 'ap-northeast-1')

item = {
  'id' => 'bar',
  'foo' => StringIO.new('baz')
}
client.put_item(table_name: 'foobar', item: item)
NoMethodError: undefined method `read' for "baz":String
from .../vendor/bundler/ruby/2.1.0/gems/aws-sdk-core-2.0.47/lib/aws-sdk-core/json/builder.rb:54:in `format'

原因

aws-sdkのバージョン2.0.47以前にDynamoDBのバイナリデータ登録に関する不具合が存在する。

対策

2.0.48で修正されているのでバージョンアップすることで解決。

リリースノート抜粋:

Issue - Aws::DynamoDB - Resolve an issue where IO objects were not properly marshaled, leading to runtime errors.

参考

該当のIssue:

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1