[serial-console] Fix garbled console output by decoding binary websocket frames#9797
[serial-console] Fix garbled console output by decoding binary websocket frames#9797muram wants to merge 2 commits intoAzure:mainfrom
Conversation
…ket frames The serial-console extension's on_message callback assumed websocket frames were always str. Newer versions of websocket-client (>= 1.0) return bytes for binary frames, which the extension passed straight into print() and got rendered as a Python bytes repr (b'...\r\n \x1b[0;32m...'). This makes the serial console unusable on recent Python/websocket-client combinations (reproduced on Python 3.13 with the vendored websocket-client 1.3.1). Decode bytes to str inside on_message so that ANSI escapes and CR/LF are interpreted by the user's terminal as intended. Bumps version to 1.0.0b4 and adds a HISTORY.rst entry. Fixes Azure#9796 Made-with: Cursor
️✔️Azure CLI Extensions Breaking Change Test
|
|
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 @muram! We will review the pull request and get back to you soon. |
|
@microsoft-github-policy-service agree |
|
Please fix CI issues |
…conflicts Fix CI failure on PR Azure#9797: 1. The serial-console extension pinned `websocket-client==1.3.1`, but recent azure-cli requires `websocket-client~=1.8.0`. Installing the extension into an env that already has azure-cli triggers `pkg_resources.ContextualVersionConflict` and `azdev extension add` fails. Widen the pin to `~=1.8.0` to match azure-cli and stay within the same major series. 2. In `.github/workflows/VersionCalPRComment.yml`, `azdev setup` runs after `pip install azdev` and installs azure-cli's pinned requirements, which downgrade transitive deps that azdev itself relies on: - azure-cli-diff-tool 0.1.1 needs requests~=2.32.3 but azure-cli pins requests==2.33.0 - tox 4.53.0 needs packaging>=26 but azure-cli pins packaging==25.0 Re-pin those two packages after `azdev setup` so the environment is internally consistent before the metadata generation step runs. Also add a non-fatal `pip check` for visibility. Made-with: Cursor
|
|
Pushed a follow-up commit to fix the failing
Re-running CI now. |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
Related command
az serial-console connectDescription
Fixes #9796.
The
serial-consoleextension'son_messagecallback inSerialConsole.connect()assumed websocket frames were alwaysstr. Newer versions ofwebsocket-client(>= 1.0, including the vendored1.3.1) returnbytesfor binary frames, which the extension passed straight into Python's built-inprint()— producing abytesrepr (b'...\r\n\x1b[0;32m...') in the user's terminal instead of decoded text. This makes the serial console unusable on recent Python/websocket-client combinations (reliably reproduced on Python 3.13).Sample of the broken output before this fix:
Change
In
src/serial-console/azext_serialconsole/custom.py, decodebytes/bytearraytostr(UTF-8 witherrors="replace"for safety) before forwarding the message toPC.print. After this change, ANSI escapes and CR/LF are interpreted by the user's terminal as intended and the serial console renders normally.Versioning
serial-consolefrom1.0.0b3to1.0.0b4.HISTORY.rstentry.Testing
az serial-console connect --resource-group <rg> --name <vmss> --instance-id <id>shows literalb'...'blob instead of console output.__pycache__), the same command renders the cloud-init / login boot log normally with proper newlines and colors.azure-cli 2.85.0, Python 3.13.12Notes
websocket-client < 1.0would also "fix" the symptom but is not future-proof and conflicts with downstream Python compatibility.