Really? What am I missing?

So I get this error:

NoMethodError

undefined method `[]’ for nil:NilClass

Which comes from this line:

627>> revision node[:sgbase][:branch]

Called by a recipe in a file that does this:

“cookbook_versions”: {
“cpan”: “= 1.0.0”,
“apt”: “= 1.0.0”,
“sgbase”: “= 1.0.0”,
“branch”: “= 1.0.0”

sgbase and branch ARE defined - why the NULL error?

mjb.

I apologize if this seems a bit unhelpful, but I'd like to mention that
I've never seen this error in a case where both levels of the mash were
defined. Usually what happens is I think they are, but after some
troubleshooting and researching, I notice that I'd hit a corner case in a
recipe where it wasn't being defined as i'd expected.

I'm a little confused by your example, in that "cookbook_versions" does not
seem related to your question at hand -- "cookbook_versions" set in an
environment don't show up as an attribute on a node; but if they did, the
structure you shared would appear as something like:
node[:cookbook_versions][:sgbase] or node[:cookbook_versions][:branch].

Are you able to Chef::Log.info(node[:sgbase][:branch]) right before it's
called there? Can you knife node edit -a and see the expected attributes
defined (branch nested in sgbase) and saved against your node?

Brian

On Thu, Dec 6, 2012 at 11:48 PM, Mark J Bradakis mark@bradakis.com wrote:

So I get this error:

NoMethodError

undefined method `' for nil:NilClass

Which comes from this line:

627>> revision node[:sgbase][:branch]

Called by a recipe in a file that does this:

"cookbook_versions": {
"cpan": "= 1.0.0",
"apt": "= 1.0.0",
"sgbase": "= 1.0.0",
"branch": "= 1.0.0"
...

sgbase and branch ARE defined - why the NULL error?

mjb.