-
-
Notifications
You must be signed in to change notification settings - Fork 747
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
''utf-8'' codec can''t decode byte 0x82 in position XX: invalid start byte' #6034
Comments
This looks like old 2.7 code. remove the |
if this is in st2 core, we will need to fix it actually. |
@guzzijones - Could you please elaborate the steps. On which file, .decode should be removed ? |
The issue is, that logic only runs when the response is I note in pywinrm's test runner, that they define a unicode round trip test: https://github.com/diyan/pywinrm/blob/f796b5aa15f0ce6c3e16aa3fd33a13efedff4937/winrm/tests/test_integration_protocol.py#L8C41-L8C55 There they define the codepage as 65001 (which is Windows for UTF-8): shell_id = protocol_real.open_shell(codepage=65001) ..with the default codepage being 437. Considering we have a custom function here to extend what pywinrm offers as arguments, we should consider setting this to 65001 so the binary response is actually UTF-8 and can be decoded as such. |
This change opens a shell with the 65001 codepage, ensuring raw string responses are UTF-8 encoded. Fixes StackStorm#6034.
This change opens a shell with the 65001 codepage, ensuring raw string responses are UTF-8 encoded. Fixes StackStorm#6034.
This change opens a shell with the 65001 codepage, ensuring raw string responses are UTF-8 encoded. Fixes StackStorm#6034.
Thanks @Stealthii. Replaced the below code in winrm_base.py & issue is fixed. < shell_id = session.protocol.open_shell(env_vars=env, working_directory=cwd, codepage=65001)
|
This change opens a shell with the 65001 codepage, ensuring raw string responses are UTF-8 encoded. Fixes StackStorm#6034.
* Drop six use for binary/string type identification With Python 3.6 being the minimum supported version, dropping six here and utilising 3.x type identifiers. * Use UTF-8 codepage in pywinrm shells This change opens a shell with the 65001 codepage, ensuring raw string responses are UTF-8 encoded. Fixes #6034.
Stackstorm winrm_ps_script action failure to stdout the non ascii characters
st2 version - 3.8.0
OS environment - RHEL 7
[root@server1 actions]# st2 run default.Ad_user_validation
..
id: 652788a0aec49d1752a2aaf0
action.ref: default.Ad_user_validation
context.user: st2admin
parameters:
password: '********'
username: svc_user
status: failed
start_timestamp: Thu, 12 Oct 2023 05:48:16 UTC
end_timestamp: Thu, 12 Oct 2023 05:48:18 UTC
result:
error: '''utf-8'' codec can''t decode byte 0x82 in position 36: invalid start byte'
traceback: " File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2actions/container/base.py", line 132, in _do_run
(status, result, context) = runner.run(action_params)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/winrm_runner/winrm_ps_script_runner.py", line 47, in run
return self.run_ps(ps_script, ps_params)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/winrm_runner/winrm_base.py", line 381, in run_ps
return self._run_ps(encoded_ps, is_b64=True)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/winrm_runner/winrm_base.py", line 396, in _run_ps
return self._translate_response(response)
File "/opt/stackstorm/st2/lib/python3.6/site-packages/winrm_runner/winrm_base.py", line 261, in _translate_response
result["stdout"] = result["stdout"].decode("utf-8")
"
The text was updated successfully, but these errors were encountered: