From 973fa0e1c264be0336205a6390ef1125052d1c75 Mon Sep 17 00:00:00 2001 From: Praveen K Paladugu Date: Thu, 9 Apr 2026 15:23:34 -0500 Subject: [PATCH] serial-console: decode binary WebSocket frames before printing 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: https://github.com/Azure/azure-cli/issues/33164 Signed-off-by: Praveen K Paladugu Signed-off-by: GitHub Copilot --- src/serial-console/azext_serialconsole/custom.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/serial-console/azext_serialconsole/custom.py b/src/serial-console/azext_serialconsole/custom.py index d1edf3338bb..b0c6cde4dad 100644 --- a/src/serial-console/azext_serialconsole/custom.py +++ b/src/serial-console/azext_serialconsole/custom.py @@ -438,6 +438,8 @@ def on_message(_, message): GV.loading = False PC.clear_screen() else: + if isinstance(message, bytes): + message = message.decode('utf-8', errors='replace') PC.print(message) def on_error(*_):