Skip to content

fix(msb): acq ports drops all but the last port when jq emits CRLF (Windows) #648

Closed

Description

@mogul

🤖: AI agent (First Mate), filing on behalf of @mogul from a Windows-host validation run reported on #644.

Problem

On a Windows host with a native Windows jq (installed via WinGet, used from Git Bash), _acq_msb_ports_from_inspect in acq.backends/msb.sh drops every port record except the last one. acq ports (LIST mode) therefore under-reports create-time ports.

Evidence

  • Windows 11 (build 26200), Git for Windows Git Bash, native jq from WinGet, tested against main at ec73abd.
  • test/bats/112-msb-ports.bats, test "msb ports: LIST mode surfaces create-time + post-hoc ports without host_bind junk" is not ok on main (identical TAP output on the PR 644 branch, so it is pre-existing and not caused by that PR).
  • Reported root cause (from the Windows-side agent; reproduced there with an A/B run, not independently reproduced here): native Windows jq writes CRLF line endings. The loop in _acq_msb_ports_from_inspect validates each port with case "$h" in ""|*[!0-9]*) continue ;; esac (and the same for $g), so a value with a trailing \r is skipped. Only the last record, which has no trailing \r, survives. Stripping \r makes the test pass.

Suggested fix

Strip carriage returns from the jq output (for example tr -d '\r' on $lines) before the digit validation. Keep the digit guard. Add a regression test that feeds CRLF jq output (stub jq that emits \r\n) and expects all ports to be listed.

Scope

Separate Windows-portability defect in the msb backend; not part of the provider-input work in #644. Not security-relevant.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions