Skip to content

Fix Linux recordings: script(1) invocation rejected by util-linux 2.41 (Bsn.Host 0.2.4) - #23

Open
soroshsabz wants to merge 2 commits into
mainfrom
fix/linux-script-arguments
Open

soroshsabz wants to merge 2 commits into
mainfrom
fix/linux-script-arguments

Conversation

@soroshsabz

@soroshsabz soroshsabz commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

ITNOA

What you hit

On Ubuntu 26.04 (WSL2 or bare metal, util-linux 2.41), every
Start-InteractiveTranscript recording came back empty:

script: unexpected number of arguments
exit: 1 duration: 0.012 stopped: False
events: 0

Root cause + why CI never caught it

The script(1) engine combined --log-out <file> with a trailing
positional typescript file (/dev/null) in one invocation. Docker
verification of the real binaries refined the version matrix:

util-linux distro options-only options+positional
2.34 Ubuntu 20.04 n/a - no --log-timing, engine uses the approximated-timing branch n/a
2.37.2 Ubuntu 22.04 works works
2.39.3 Ubuntu 24.04 works REJECTED
2.41.3 Ubuntu 26.04 works REJECTED

So Ubuntu 24.04 was broken too, not just 26.04. And the script(1)
engine had zero end-to-end CI coverage: every Unix system test
skips under CI redirected stdio - only unit tests ran on Linux CI, and
they never invoke script(1).

What ships (Bsn.Host 0.2.4)

  • Resolve-BsnScriptInvocation (new private helper): probes the
    installed script(1) binary once
    with a no-op child and picks the
    invocation shape it accepts - the historically tested positional form
    where supported (22.04 and older, zero behavior change), the
    options-only form where rejected (24.04/26.04). No util-linux version
    string parsing; future releases are handled by the same probe.
  • New CI-runnable Linux/macOS system test: records a -Command session
    (randomized marker + uname -s) through the script(1) engine and
    asserts markers, kernel name and zero U+FFFD land in the cast. It
    intentionally runs under CI redirected stdio (script(1) allocates its
    own PTY and echo children need no stdin), pinning the regression on
    CI from now on.
  • New unit tests for the invocation probe with fake script(1) shims
    (accepting -> positional form kept; rejecting -> options-only form),
    covering both branches on Linux/macOS CI.
  • CI matrix: adds a pinned ubuntu-24.04 image alongside
    ubuntu-latest (26.04) so two util-linux generations exercise the
    script(1) engine on every pull request - this class of bug cannot
    silently return.
  • AGENTS.md documents the version-sensitivity and the probe design.
  • Bsn.Host 0.2.4; Bsn.Common / Bsn.SystemManagement unchanged.

Verified

  • WSL2 Ubuntu 26.04.1 (util-linux 2.41.3, pwsh 7.6.5): failure
    reproduced before the fix (script: unexpected number of arguments,
    0 events); after the fix: exit 0, randomized marker + kernel release
    captured, zero U+FFFD, playback renders the session.
  • Docker: ubuntu:20.04 (2.34), ubuntu:22.04 (2.37.2), ubuntu:24.04
    (2.39.3) - all four invocation-form checks above executed against the
    real binaries.
  • Helper unit tests green on WSL (both branches against the real
    probe); Windows gate: analyzer clean, 96 tests green.

- Drop the redundant positional typescript file from the util-linux
  script(1) invocation: util-linux 2.41 rejects combining --log-out with
  a positional file ("unexpected number of arguments"), so every
  recording on Ubuntu 26.04 exited immediately with 0 events.
- Add a CI-runnable Linux/macOS system test that records a -Command
  session through the script(1) engine and asserts markers/zero U+FFFD -
  the script(1) engine previously had no end-to-end CI coverage because
  every Unix system test skipped under CI redirected stdio.
- Bsn.Host 0.2.4; AGENTS.md documents the util-linux 2.41 constraint.

Verified on WSL2 Ubuntu 26.04.1 (util-linux 2.41.3, pwsh 7.6.5): the
failure is reproduced before the fix and recordings capture markers,
kernel release and clean playback after it. Windows gate: analyzer
clean, 96 tests green.
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 522b10d8-955c-4636-aec4-16e5d1899485
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.00000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...c/Bsn.Host/Private/Resolve-BsnScriptInvocation.ps1 84.21% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

…04 CI image

The first fix hardcoded the options-only invocation, which is unverified
on older distros and would silently change behavior there. Docker
verification of the real script(1) binaries refined the matrix:

- util-linux 2.34 (Ubuntu 20.04): no --log-timing at all - the engine
  uses the approximated-timing (BSD-style) branch, never the buggy form.
- util-linux 2.37.2 (Ubuntu 22.04): BOTH shapes work.
- util-linux 2.39.3 (Ubuntu 24.04): positional form REJECTED - 24.04
  was broken by the same bug as 26.04 (2.41.3), not just 26.04.
- util-linux 2.41.3 (Ubuntu 26.04): positional form REJECTED.

Instead of parsing version strings, the engine now probes the installed
script(1) binary once with a no-op child: where the classic positional
form is accepted (22.04 and older) it is kept unchanged; where it is
rejected (24.04/26.04) the options-only form is used. New private
Resolve-BsnScriptInvocationArguments-free helper
Resolve-BsnScriptInvocation implements the probe, deterministic on any
future util-linux release.

Tests:
- Unit: Resolve-BsnScriptInvocation with fake script(1) shims - a
  shim that exits 0 must keep the positional form, one that exits 1
  must get the options-only form, and both shapes must carry the
  recorded command and both log paths (runs on Linux/macOS CI;
  Windows skips - no Unix exec-bit shims).
- System: the Unix -Command recording test (from the previous commit)
  runs on ubuntu CI images and pins the end-to-end behavior.
- CI matrix: add a pinned ubuntu-24.04 image alongside ubuntu-latest so
  two util-linux generations (2.39 and 2.41) exercise the script(1)
  engine on every pull request.
@sonarqubecloud

sonarqubecloud Bot commented Nov 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant