Skip to content

Detect Hiera files that are not valid hashes#184

Merged
bastelfreak merged 1 commit into
voxpupuli:masterfrom
bastelfreak:bug
May 23, 2025
Merged

Detect Hiera files that are not valid hashes#184
bastelfreak merged 1 commit into
voxpupuli:masterfrom
bastelfreak:bug

Conversation

@bastelfreak

Copy link
Copy Markdown
Member

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

@bastelfreak bastelfreak self-assigned this May 22, 2025
@bastelfreak bastelfreak added the enhancement New feature or request label May 22, 2025
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
```
@kenyon kenyon changed the title Detect Hiera files that are no valid hash Detect Hiera files that are not valid hashes May 23, 2025
@bastelfreak bastelfreak merged commit 2d0709a into voxpupuli:master May 23, 2025
16 checks passed
@bastelfreak bastelfreak deleted the bug branch May 23, 2025 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants