puppetlabs / puppetlabs/bolt

Unit tests/spec: Invalid inventoryfile structure can cause hard to debug error

Open
#3,345 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug
Dominant language
Ruby
Stars
558
Forks
224
Avg merge
1h 4m
Merged PRs (30d)
1

Description

Describe the Bug

Same as #2430 but for unit tests. Accidentally loaded an inventory yaml file without a groups key:

- name: somegroup
  targets:
    - alias: somealias
      name: somename
      uri: some.uri

running a unit test using it returns

...  instead of raising Puppet::PreformattedError(Evaluation Error: Error while evaluating a Function Call, undefined method `key?' for [{"name"=>"somegroup", "targets"=>[{"alias"=>"somealias", "name"=>"somename", "uri"=>"some.uri"}]}]:Array

Expected Behavior

Print a clear error that the inventory structure is invalid

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Compare this unit-test case with issue #2430 and trace the inventory YAML loading path used by unit tests. Reproduce the missing groups key structure, then add coverage showing that it raises a clear invalid-inventory error instead of the current key? failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.