From 1a53718cc5971b260db26c65c64dff958ffca8fd Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Mon, 11 May 2026 13:41:09 -0400 Subject: [PATCH] fix: SSH shell quoting bug breaks ethtool collection; ticket_id KeyError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit monitor.py _ssh_batch(): the remote command was wrapped in double-quotes (f'root@{ip} "{shell_cmd}"') but shell_cmd itself contains double-quoted echo sentinels ("___IFACE:eth0___"). When Pulse's shell parses the full ssh invocation, the nested double-quotes cause mis-parsing — the remote command is split incorrectly, silently breaking all ethtool/SFP DOM collection. Fix: use shlex.quote(shell_cmd) so the entire remote command is single-quoted, leaving inner double-quotes untouched. TicketClient.create(): data['ticket_id'] raises KeyError if the Tinker Tickets API returns success=true without a ticket_id field (malformed response). Use data.get('ticket_id') with an explicit warning log. Co-Authored-By: Claude Sonnet 4.6 --- monitor.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index d0c5463..e8b77c2 100644 --- a/monitor.py +++ b/monitor.py @@ -215,7 +215,10 @@ class TicketClient: resp.raise_for_status() data = resp.json() if data.get('success'): - tid = data['ticket_id'] + tid = data.get('ticket_id') + if not tid: + logger.warning(f'Ticket API success but no ticket_id in response: {data}') + return None logger.info(f'Created ticket #{tid}: {title}') return tid if data.get('existing_ticket_id'): @@ -377,7 +380,7 @@ class LinkStatsCollector: f'ssh -o StrictHostKeyChecking=accept-new -o ConnectTimeout=5 ' f'-o BatchMode=yes -o LogLevel=ERROR ' f'-o ServerAliveInterval=10 -o ServerAliveCountMax=2 ' - f'root@{ip} "{shell_cmd}"' + f'root@{ip} {shlex.quote(shell_cmd)}' ) output = self.pulse.run_command(ssh_cmd) if output is None: