0.9.14 removed #symbolize_keys


#1

So on 0.9.12 this was working fine:

template “/etc/init.d/unicorn-#{app_id}” do
mode 0755
variables app.symbolize_keys.to_hash
source "init-unicorn.erb"
cookbook "application"
end

After upgrading to 0.9.14 however:

/var/cache/chef/cookbooks/application/recipes/unicorn.rb:63:in from_file': undefined methodsymbolize_keys’ for Chef::DataBagItem:0x7f9419a8be98 (NoMethodError)

Thoughts? Should this not have worked in the first place?

-ash


#2

It looks like you were counting on Data Bags to be a Hash, they’re now
proper Data Bag objects so you’ll need to update your syntax. Chef
0.9.14 fixed it in this ticket:
http://tickets.opscode.com/browse/CHEF-1988

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

On Fri, Mar 11, 2011 at 5:56 AM, Ash Berlin ash_opscode@firemirror.com wrote:

So on 0.9.12 this was working fine:

template “/etc/init.d/unicorn-#{app_id}” do
mode 0755
variables app.symbolize_keys.to_hash
source "init-unicorn.erb"
cookbook "application"
end

After upgrading to 0.9.14 however:

/var/cache/chef/cookbooks/application/recipes/unicorn.rb:63:in from_file': undefined methodsymbolize_keys’ for Chef::DataBagItem:0x7f9419a8be98 (NoMethodError)

Thoughts? Should this not have worked in the first place?

-ash


#3

On Friday, March 11, 2011 at 5:24 AM, Matt Ray wrote:
It looks like you were counting on Data Bags to be a Hash, they’re now

proper Data Bag objects so you’ll need to update your syntax. Chef
0.9.14 fixed it in this ticket:
http://tickets.opscode.com/browse/CHEF-1988

Data Bag Item defines all of the methods of Hash and forwards them to the raw data object, so you can generally treat it like a Hash. What you’re seeing is that #symbolize_keys is a monkey patch from activesupport, which DataBagItem does not implement. If you need to use activesupport’s monkey patches, grab raw_data and call those methods on it.

HTH,


Dan DeLeo

Thanks,

Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

On Fri, Mar 11, 2011 at 5:56 AM, Ash Berlin ash_opscode@firemirror.com wrote:

So on 0.9.12 this was working fine:

template “/etc/init.d/unicorn-#{app_id}” do
mode 0755
variables app.symbolize_keys.to_hash
source "init-unicorn.erb"
cookbook "application"
end

After upgrading to 0.9.14 however:

/var/cache/chef/cookbooks/application/recipes/unicorn.rb:63:in from_file': undefined methodsymbolize_keys’ for Chef::DataBagItem:0x7f9419a8be98 (NoMethodError)

Thoughts? Should this not have worked in the first place?

-ash


#4

Since we probably weren’t loading active_support, could this have been
coming from extlib?

Adam

On Fri, Mar 11, 2011 at 7:28 AM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, March 11, 2011 at 5:24 AM, Matt Ray wrote:

It looks like you were counting on Data Bags to be a Hash, they’re now
proper Data Bag objects so you’ll need to update your syntax. Chef
0.9.14 fixed it in this ticket:
http://tickets.opscode.com/browse/CHEF-1988

Data Bag Item defines all of the methods of Hash and forwards them to the
raw data object, so you can generally treat it like a Hash. What you’re
seeing is that #symbolize_keys is a monkey patch from activesupport, which
DataBagItem does not implement. If you need to use activesupport’s monkey
patches, grab raw_data and call those methods on it.

HTH,

Dan DeLeo

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

On Fri, Mar 11, 2011 at 5:56 AM, Ash Berlin ash_opscode@firemirror.com
wrote:

So on 0.9.12 this was working fine:

template “/etc/init.d/unicorn-#{app_id}” do
mode 0755
variables app.symbolize_keys.to_hash
source "init-unicorn.erb"
cookbook "application"
end

After upgrading to 0.9.14 however:

/var/cache/chef/cookbooks/application/recipes/unicorn.rb:63:in from_file': undefined methodsymbolize_keys’ for Chef::DataBagItem:0x7f9419a8be98
(NoMethodError)

Thoughts? Should this not have worked in the first place?

-ash


Opscode, Inc.
Adam Jacob, Chief Product Officer
T: (206) 619-7151 E: adam@opscode.com


#5

Changing

app.symbolize_keys.to_hash

to

app.to_hash.symbolize_keys

seemed to be the magic that was needed.

-ash

On 11 Mar 2011, at 19:17, Adam Jacob wrote:

Since we probably weren’t loading active_support, could this have been
coming from extlib?

Adam

On Fri, Mar 11, 2011 at 7:28 AM, Daniel DeLeo dan@kallistec.com wrote:

On Friday, March 11, 2011 at 5:24 AM, Matt Ray wrote:

It looks like you were counting on Data Bags to be a Hash, they’re now
proper Data Bag objects so you’ll need to update your syntax. Chef
0.9.14 fixed it in this ticket:
http://tickets.opscode.com/browse/CHEF-1988

Data Bag Item defines all of the methods of Hash and forwards them to the
raw data object, so you can generally treat it like a Hash. What you’re
seeing is that #symbolize_keys is a monkey patch from activesupport, which
DataBagItem does not implement. If you need to use activesupport’s monkey
patches, grab raw_data and call those methods on it.

HTH,

Dan DeLeo

Thanks,
Matt Ray
Technical Evangelist | Opscode, Inc
E: matt@opscode.com T: (512) 731-2218
Twitter, Github: mattray

On Fri, Mar 11, 2011 at 5:56 AM, Ash Berlin ash_opscode@firemirror.com
wrote:

So on 0.9.12 this was working fine:

template “/etc/init.d/unicorn-#{app_id}” do
mode 0755
variables app.symbolize_keys.to_hash
source "init-unicorn.erb"
cookbook "application"
end

After upgrading to 0.9.14 however:

/var/cache/chef/cookbooks/application/recipes/unicorn.rb:63:in from_file': undefined methodsymbolize_keys’ for Chef::DataBagItem:0x7f9419a8be98
(NoMethodError)

Thoughts? Should this not have worked in the first place?

-ash