-
Notifications
You must be signed in to change notification settings - Fork 202
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
Fix 'invalid char in json text' error #161
Conversation
Assigning to myself so we will review this during bug triage |
@zl4bv Nice catch and thanks for the PR. I'm no Windows expert - will this work on Windows Server 2008? I'm guessing it more depends on the version of Powershell present? |
As far as I know PowerShell has always used UTF-16 encoding (with BOM) as the default. This thread leads me to believe this has been the case since at least PowerShell 2.0. When you call the |
The |
I would like to get @smurawski's opinion, but I am 👍 |
@@ -427,7 +427,7 @@ def hostname(server, interface_type = nil) | |||
|
|||
def create_ec2_json(state) | |||
if windows_os? | |||
cmd = "mkdir \\etc\\chef\\ohai\\hints; echo $null >> \\etc\\chef\\ohai\\hints\\ec2.json" | |||
cmd = "New-Item -Force C:\\chef\\ohai\\hints\\ec2.json -Type File" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Type alias (for ItemType) wasn't introduced until PowerShell 3. Server 2008R2 ships with PS 2 by default and this will work fine if you change the parameter to -ItemType
(which will be valid from PowerShell 1 and up)
@zl4bv @tyler-ball I'd just make that one parameter name change and then I'm 👍 |
Fix 'invalid char in json text' error
Thanks for the suggestion @smurawski :) Did you still want me to change the parameter name @tyler-ball? |
@zl4bv I did it when I merged it - thanks for the initial contribution! |
After further testing and closer inspection of the Chef logs, it seems my change in #134 introduced a different kind of error:
Apparently the method I used inserts a UTF-16 byte order mark.
The fix in this PR creates an empty file with no BOM.