Jira (HI-514) Better error reporting for hiera type mismatch

4 views
Skip to first unread message

Andrew Wasilczuk (JIRA)

unread,
May 17, 2016, 7:18:02 AM5/17/16
to puppe...@googlegroups.com
Andrew Wasilczuk created an issue
 
Hiera / Bug HI-514
Better error reporting for hiera type mismatch
Issue Type: Bug Bug
Affects Versions: HI 1.3.4
Assignee: Unassigned
Components: Community
Created: 2016/05/17 4:17 AM
Environment:

CentOS 6

Priority: Normal Normal
Reporter: Andrew Wasilczuk

The hiera_hash function fails with type error when a key is empty (or wrong type), which makes sense but the error message doesn't provide much information to help debug the issue:

Error: Could not run: Hiera type mismatch: expected Hash and got NilClass

It would be nice if it contained:

  • Where in puppet manifest was hiera_hash function called from (file name + line number)
  • Where in hiera is the offending key stored (file name + line number)

Here is an example to reproduce the issue:

#-- Assuming hiera.yaml
:hierarchy:
   - web01.example.com
   - common
 
#-- Assuming common.yaml:
users:
   regular:
     'cdouglas': 'Carrie Douglas'
 
#-- Assuming web01.example.com.yaml:
users:
#   administrators:
#     'aberry': 'Amy Berry'

#-- Assuming we are web01.example.com:
 
$allusers = hiera_hash('users')

The case where I saw this happen is when user hashed out a bunch of values but left the top level key as illustrated above. Took a while to hunt it down in the hierarchy and wasn't immediately obvious what happened.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Henrik Lindberg (JIRA)

unread,
May 17, 2016, 12:06:04 PM5/17/16
to puppe...@googlegroups.com
Henrik Lindberg assigned an issue to Andrew Wasilczuk
Change By: Henrik Lindberg
Assignee: Andrew Wasilczuk

Henrik Lindberg (JIRA)

unread,
May 17, 2016, 12:06:04 PM5/17/16
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug HI-514
 
Re: Better error reporting for hiera type mismatch

Which Puppet version are you using? (The error handling and reporting of line numbers etc. is done on the puppet side, not inside of hiera).
If you are on a newer puppet, you can use the lookup function and the functionality that is offered by the lookup CLI which among other things have an --explain option.

Josh Cooper (Jira)

unread,
Feb 17, 2022, 2:06:02 AM2/17/22
to puppe...@googlegroups.com
Josh Cooper commented on Bug HI-514

The hiera_hash method is deprecated and we won’t be making any changes to it, so I’m going to close this.

Instead use the lookup function as it provides better information when actual and expected types don’t match.

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages