Reading binary file using file::read in bolt plan, causes apply blocks to fail.
benjamin-robertson opened this issue · 1 comments
Describe the Bug
Reading a binary file into a string using file::read within a bolt plan causes apply blocks to fail.
I am able to use the write_file function to write the binary file out to systems and this works as expected.
Expected Behavior
Apply blocks should still function even if a binary file is read into a string variable.
Steps to Reproduce
Steps to reproduce the behavior:
Read binary file into a string.
$test_file = file::read('/usr/bin/vim')
Attempt to use an apply block in the same plan. You don't need to use this variable in the apply block. Its existence within the plan is enough to cause it to fail.
$apply_results = apply($linux_targets) {
file { '/tmp/test':
ensure => file,
}
When the plan is run, the apply blocks will fail with the following message.
Failed on ip-10-64-194-133.ap-southeast-2.compute.internal:
Apply failed to compile for ip-10-64-194-133.ap-southeast-2.compute.internal: source sequence is illegal/malformed utf-8
Environment
- Bolt 3.30
- Ubuntu 22.04
Additional Context
I'm assuming this is occurring as local variables from the plan are accessible within the apply block. When transforming the value for the apply block its expecting utf8. https://dev.to/bajena/solving-invalid-byte-sequence-in-utf-8-errors-in-ruby-1f27
Thanks for the report. Yeah variables in plan scope need to be serialized to json to be passed to the compile process. My guess is that something along the way is choking on that. From a quick glance it looks like our data converter is being invoked with rich_data option
Line 218 in 40b726c