Skip to content

serial-console: decode binary WebSocket frames before printing#9772

Open
praveen-pk wants to merge 1 commit intoAzure:mainfrom
praveen-pk:console_fix
Open

serial-console: decode binary WebSocket frames before printing#9772
praveen-pk wants to merge 1 commit intoAzure:mainfrom
praveen-pk:console_fix

Conversation

@praveen-pk
Copy link
Copy Markdown

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

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

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.json automatically.
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.

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>
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

Copilot AI review requested due to automatic review settings April 9, 2026 20:27
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @praveen-pk,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Apr 9, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Apr 9, 2026
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Thank you for your contribution @praveen-pk! We will review the pull request and get back to you soon.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 bytes WebSocket messages using UTF-8 with errors='replace' before calling PC.print().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot customer-reported Issues that are reported by GitHub users external to the Azure organization. Serial Console

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az serial-console connect prints raw Python bytes

4 participants