Just checking in to see if you have had a chance to see the previous response. Could you share the above required information to understand/investigate this issue further?
We had a similar issue with creating .json files using Powershell and the Out-File command.
It would produce the file just fine (so we thought), but when we tried to parse it from a bash command in a YAML pipeline it threw an error saying it’s not valid json.
We ended up finding out that the Out-File command added some non-printable characters to the start of the file. Basically we needed a specific encoding on the file.
We had to include an encoding parameter with our out-file command to encode it the way we needed it (UTF8).
Perhaps you would need to explicitly state the encoding needed when creating the file or writing to the file?
This might not explain why it’s intermittent unless for some reason the default encoding is different for the different instances running this code.