puppetlabs / puppetlabs/puppetlabs-stdlib
loadjson returns StringIO data which doesn't work in Puppet 8
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 349
- Forks
- 573
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 1
Description
Describe the Bug
When using loadjson in a puppet manifest with small json files, the returning Data values come in as a StringIO instead of String value which Puppet 8 can't cast properly.
Expected Behavior
Return a hash of Strings.
Steps to Reproduce
Steps to reproduce the behavior:
- Use loadjson as documented to pull in a json file that you want to convert to hash.
- Run puppet agent and see the error.
Environment
- RedHat Enterprise Linux 8
- Puppet 8.3.0
Additional Context
I was able to fix this by editing the loadjson ruby code lines 56 and 63 changing from
JSON.parse(content) || args[1]
to
JSON.parse(content.string) || args[1]
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Search the Ruby implementation of loadjson and inspect the code around lines 56 and 63, then reproduce the issue with Puppet 8.3.0 using a small JSON file. Done means loadjson returns a hash whose values are Strings and the Puppet agent no longer reports a casting error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100