Ask Your Question

Handling Error 400 on Undef Gracefully

asked 2015-07-09 09:30:06 -0600

Antitribu gravatar image

updated 2015-07-09 10:40:14 -0600

We are receiving the following error:

Jul 9 15:16:12 server puppet-agent[10183]: Could not retrieve catalog from remote server: Error 400 on SERVER: $$jboss_hiera[$project][$application] is :undef, not a hash or array at /etc/puppet/environments/production/modules/jboss/manifests/applications/application.pp:39 on node server.local

The Hiera looks like:


    version: 6.5
        val1: 1234
        val2: 5678

    version: 6.5
      foo: bar
      grr: hmm

The pp (line 39-41) file reads something like

  if $jboss_hiera[$project][$application]['application_properties'] != undef {
    $jboss_application_properties = $jboss_hiera[$project][$application]['application_properties']

So the code is supposed to catch an undefined variable and handle this gracefully if it doesn't exist (as it may well not). However for values of project/application other than project1/app1 this does not happen. I've tried changing the hiera lookup default value to false with no luck.

Any suggestions?


edit retag flag offensive close merge delete


Ended up working around using nested ifs in the template, so an exists for each level of the hash is checked before moving onto the next one,

Antitribu gravatar imageAntitribu ( 2015-07-09 10:41:00 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2015-07-11 04:08:34 -0600

The issue here is probably that the key $jboss_hiera[$project][$application] doesn't exist.

You probably want something like

if $jboss_hiera[$project] and
   $jboss_hiera[$project][$application] and
  $jboss_application_properties = $jboss_hiera[$project][$application]['application_properties']
edit flag offensive delete link more


Thanks, looks like this is it. I ended up implementing this in the template however as multiple if's. If it is all as one if statement will it evaluate in order and not throw an error? Thanks

Antitribu gravatar imageAntitribu ( 2015-07-13 01:31:21 -0600 )edit

Yes that's right.

Alex Harvey gravatar imageAlex Harvey ( 2015-07-13 19:27:25 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2015-07-09 09:30:06 -0600

Seen: 147 times

Last updated: Jul 11 '15