Commit 278cbfb
committed
Detect Hiera files that are no valid hash
This was reported on slack via @ikonia. with such malformed keys, Hiera
just reports a string:
```
irb(main):002> require 'yaml'
=> true
irb(main):003> yamlargs = (Psych::VERSION >= '4.0') ? { aliases: true } : {}
=> {aliases: true}
irb(main):004> hiera_file='spec/fixtures/hiera/hiera_key_no_value.yaml'
=> "spec/fixtures/hiera/hiera_key_no_value.yaml"
irb(main):005> YAML.load_file(hiera_file, **yamlargs)
=> "prometheus::initstyle:sysv prometheus::node_exporter::init_style:sysv"
irb(main):006>
```
And puppetserver will fail to compile a catalog:
```
Notice: Catalog compiled by ***
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, /etc/puppetlabs/code/environments/***.yaml: file does not contain a valid yaml hash on node ***
Warning: Not using cache on failed catalog
```1 parent 26e931d commit 278cbfb
3 files changed
Lines changed: 15 additions & 0 deletions
File tree
- lib/puppet-syntax
- spec
- fixtures/hiera
- puppet-syntax
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
| |||
0 commit comments