Fix WebCRT connect crash from invalid Netmiko session_log wrapper.

Use a BytesIO subclass for live connect echo so Netmiko accepts the log object again.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-08-28 21:55:20 +08:00
parent 6ed08e24de
commit 6aedd2c522
3 changed files with 43 additions and 48 deletions

View file

@ -19,6 +19,7 @@ from .ne_session_factory import (
get_cli_hop_guard,
open_netmiko_connection,
)
from .ne_session_connect import _ProgressBytesIO
from .webcrt_channel import (
_audit,
_capture_raw_channel,
@ -222,11 +223,12 @@ def _finish_connect(
connect_timeout: int,
client: str,
) -> None:
log_buf = io.BytesIO()
def _progress(text: str) -> None:
sess.push_connect_echo(text)
# Must be BufferedIOBase subclass — Netmiko rejects custom log wrappers.
log_buf = _ProgressBytesIO(_progress)
try:
conn = open_netmiko_connection(
creds,