Ubuntu 26.04: systemd OSC 3008 context sequences end up in every command output (os_version > 255 chars) #41

Closed
opened 2026-10-23 16:44:27 +00:00 by christianmanivong · 0 comments
Owner

Prio: P1 (critical): no Ubuntu 26.04 host can be polled; the poll result is never stored.

What happens

First poll of a fresh Ubuntu 26.04.1 LTS host (KVM at IONOS, netOrk 0.40.0, napalm-linux 0.12.0, 2026-10-23). The connection and key auth succeed, then get_facts() returns an os_version like:

ESC]3008;end=<uuid>;exit=success ESC\ ESC]3008;start=<uuid>;type=command;machineid=...;user=netork;hostname=ubuntu;bootid=...;pid=...;cwd=/home/netork ESC\Ubuntu 26.04.1 LTS
ESC]3008;end=...ESC\ESC]3008;start=...;type=shell;... ESC\netork@ubuntu:~$

That is longer than 255 characters, so netOrk's UPDATE devices SET ... os_version=... fails with StringDataRightTruncationError and the device stays PLANNED.

Root cause

systemd 258 ships /etc/profile.d/80-systemd-osc-context.sh: interactive bash shells emit OSC 3008 context sequences (via PS0 / PROMPT_COMMAND) before and after every command, each carrying a fresh UUID.

  1. LinuxDriver._send() returns netmiko's output without strip_terminal_codes() (only _split_status strips them), so every parsed value carries the sequences.
  2. Because the sequences differ on every prompt, netmiko's strip_prompt no longer matches the prompt, so the prompt line netork@ubuntu:~$ is left in the output too.

Fix direction

  • Switch the context hooks off right after connecting, next to _HISTORY_OFF (clear PS0 and drop __systemd_osc_context_* from PROMPT_COMMAND), so the shell stops emitting them.
  • And _send() runs its output through strip_terminal_codes() as a second line of defence.
  • Fixture: real output from an Ubuntu 26.04 shell.
Prio: P1 (critical): no Ubuntu 26.04 host can be polled; the poll result is never stored. ## What happens First poll of a fresh Ubuntu 26.04.1 LTS host (KVM at IONOS, netOrk 0.40.0, napalm-linux 0.12.0, 2026-10-23). The connection and key auth succeed, then `get_facts()` returns an `os_version` like: ``` ESC]3008;end=<uuid>;exit=success ESC\ ESC]3008;start=<uuid>;type=command;machineid=...;user=netork;hostname=ubuntu;bootid=...;pid=...;cwd=/home/netork ESC\Ubuntu 26.04.1 LTS ESC]3008;end=...ESC\ESC]3008;start=...;type=shell;... ESC\netork@ubuntu:~$ ``` That is longer than 255 characters, so netOrk's `UPDATE devices SET ... os_version=...` fails with `StringDataRightTruncationError` and the device stays PLANNED. ## Root cause systemd 258 ships `/etc/profile.d/80-systemd-osc-context.sh`: interactive bash shells emit OSC 3008 context sequences (via `PS0` / `PROMPT_COMMAND`) before and after every command, each carrying a fresh UUID. 1. `LinuxDriver._send()` returns netmiko's output without `strip_terminal_codes()` (only `_split_status` strips them), so every parsed value carries the sequences. 2. Because the sequences differ on every prompt, netmiko's `strip_prompt` no longer matches the prompt, so the prompt line `netork@ubuntu:~$` is left in the output too. ## Fix direction - Switch the context hooks off right after connecting, next to `_HISTORY_OFF` (clear `PS0` and drop `__systemd_osc_context_*` from `PROMPT_COMMAND`), so the shell stops emitting them. - And `_send()` runs its output through `strip_terminal_codes()` as a second line of defence. - Fixture: real output from an Ubuntu 26.04 shell.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-linux#41