Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadjson returns StringIO data which doesn't work in Puppet 8 #1414

Open
bgibson710 opened this issue Dec 22, 2023 · 1 comment · May be fixed by #1415
Open

loadjson returns StringIO data which doesn't work in Puppet 8 #1414

bgibson710 opened this issue Dec 22, 2023 · 1 comment · May be fixed by #1415

Comments

@bgibson710
Copy link

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:

  1. Use loadjson as documented to pull in a json file that you want to convert to hash.
  2. 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]

@ekohl
Copy link
Collaborator

ekohl commented Dec 23, 2023

It looks like the tests really stub out the crucial parts which is JSON.parse and I really don't know why. What is really is the point of testing it then?

@ekohl ekohl linked a pull request Dec 23, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants