serial-console: decode binary WebSocket frames before printing#9772
serial-console: decode binary WebSocket frames before printing#9772praveen-pk wants to merge 1 commit intoAzure:mainfrom
Conversation
websocket-client delivers binary frames as Python bytes objects. Passing bytes directly to PC.print() causes print() to render them as raw repr strings (e.g. b'\r\r\n', b'login: ') instead of decoded text, which corrupts the serial console output in WSL and other non-Windows environments. Fix this by decoding bytes to str with UTF-8 (replacing invalid sequences) in on_message() before calling PC.print(). Fixes: Azure/azure-cli#33164 Signed-off-by: Praveen K Paladugu <prapal@linux.microsoft.com> Signed-off-by: GitHub Copilot <copilot@github.com>
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
Hi @praveen-pk, |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution @praveen-pk! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR fixes corrupted Azure Serial Console output on non-Windows environments (e.g., WSL) by decoding binary WebSocket frames (Python bytes) into UTF-8 text before printing them to the console.
Changes:
- Decode
bytesWebSocket messages using UTF-8 witherrors='replace'before callingPC.print().
websocket-client delivers binary frames as Python bytes objects. Passing bytes directly to PC.print() causes print() to render them as raw repr strings (e.g. b'\r\r\n', b'login: ') instead of decoded text, which corrupts the serial console output in WSL and other non-Windows environments.
Fix this by decoding bytes to str with UTF-8 (replacing invalid sequences) in on_message() before calling PC.print().
Fixes: Azure/azure-cli#33164
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)For new extensions:
About Extension Publish
There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update
src/index.jsonautomatically.You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify
src/index.json.