Skip to content

fix: six silent-failure bugs found in a repo audit - #152

Merged
dizys merged 2 commits into
dizys:mainfrom
0libote:fix/audit-six-small-fixes
Nov 20, 2026
Merged

dizys merged 2 commits into
dizys:mainfrom
0libote:fix/audit-six-small-fixes

Conversation

@0libote

@0libote 0libote commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

A full-repo audit turned up a set of small bugs with one thing in common: they fail silently. This fixes six of them — each a one-to-four-line change, each with a regression test that fails on main.

What was wrong

  • Automatic cleanup could delete the fallback toolchain it exists to keep. An upgrade interrupted before its state write leaves previousVersion naming a version that is no longer installed. No installed version matched it, so the "Previous version" protection attached to nothing, and the next automatic retention pass could remove the only remaining older version.
  • A sign-in that never printed its URL hung forever. The session TTL only rescued awaiting-* states, so a CLI stuck in starting (no network, nothing printed) was never killed and never settled. Both sibling starters already use the !TERMINAL_STATES condition; this one now does too.
  • One bad entry failed a whole zip extraction. A link entry with an empty target passed every inspection check, then fs.symlink('') threw a raw ENOENT after the other entries had already been staged.
  • t3-pair's error path was dead code. Under set -euo pipefail, a failed mint aborted the script before its own error handling — with stderr already discarded — so a failed pairing printed nothing at all. t3-expose had the same shape: one refused connection during its 40-second poll (the setup server restarts on its own 5-second loop) killed the CLI mid-"Publishing…".
  • The Connect card asked for a sign-in nobody asked for. revoked won over "not wanted", so an unlinked server whose relay link was later revoked showed signin instead of off.
  • A full state volume could erase an operation's own failure. The failure-record write in runLocked was unguarded; if it threw, it replaced the original error, skipped the post-op cleanup, and left the row reading as "interrupted".

Validation

  • Five new regression tests, each verified to fail against the unfixed code (run against the stashed originals) and pass with the fixes.
  • Focused suites all green: connect, connect-api, harness-retention, harness-manager, files-archives — 162/162.
  • Full source suite (node --test tests/*.test.mjs): 2030/2031 pass. The one failure is a temp-dir cleanup race under parallel load (ENOTEMPTY on ~/.npm/_logs while a child npm still writes into the temp home during t.after); it passes 3/3 in isolation and does not touch any file in this diff. main has the same class of parallel-load flake in connect-api.test.mjs's revocation assertion.
  • bash tests/t3-pair.test.sh passes; CI's lint job now runs it (one line in build.yml), and it is covered by the existing bash -n + shellcheck globs.
Per-fix details and known gaps
Fix File Test
Stale previousVersion falls back to the newest installed version docker/harness/retention.mjs tests/harness-retention.test.mjs
Empty zip link target disclosed and skipped docker/setup/files/zip-format.mjs tests/files-archives.test.mjs
revoked no longer overrides "not asked for" docker/setup/connect.mjs tests/connect.test.mjs
Failure-record write is best effort docker/harness/manager.mjs tests/harness-manager.test.mjs
Failed mint keeps its error handling alive docker/bin/t3-pair tests/t3-pair.test.sh (new, wired into CI lint)
Poll survives a setup-server blip docker/bin/t3-expose inspection only
Sign-in TTL rescues every non-terminal state docker/setup/server.mjs no direct test

Known gaps, stated plainly:

  • The sign-in TTL change has no direct test: SESSION_TTL_MS is 15 minutes, so covering it means refactoring the timer for injection. The change copies the identical, already-tested condition from the two sibling starters (startScmDeviceSignin, startConnectLink).
  • The t3-expose poll change is inspection-only: exercising it needs a stub setup server that fails once then answers, which the current .test.sh harness doesn't have.
  • These six were the smallest of the audit's findings; the larger ones (a PUID=0 boot loop in the entrypoint, the harness lock's 1-hour age ceiling breaking live holders, chown -R crossing nested read-only mounts) need their own PRs with heavier test harnesses.

0libote and others added 2 commits November 19, 2026 22:38
- retention: a previousVersion naming an uninstalled version (an upgrade
  interrupted before its state write) unprotects the installed fallback;
  fall back to the newest installed version
- zip: an entry with an empty symlink target passed every safety check and
  failed the whole extraction at symlink(''); disclose and skip it
- connect: revoked-but-unlinked reported 'signin' instead of 'off'
- sign-in: a session that never printed its URL was never killed or
  settled by the TTL; rescue every non-terminal state like the siblings
- manager: guard the failure-record write so a full state volume cannot
  replace the operation's own error
- t3-pair/t3-expose: keep a failed pipeline from aborting under set -e
  before the script's own error handling runs
@dizys
dizys merged commit 7782428 into dizys:main Nov 20, 2026
14 checks passed
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.

2 participants