fix(arcup): accept a checksum file with no trailing newline - #402
erkancamli wants to merge 4 commits into
Conversation
|
A severity correction on my own PR, so nobody merges this thinking users are hitting it. The only production source of the checksum file is The underlying bash behaviour is still worth guarding: Also worth flagging: |
The header comment asks for a bump on any change to this script, and self_update compares the two versions with version_gt, so an equal version means every existing install refuses the fix as "already up to date". Without this the checksum change would ship and reach nobody.
expect_fail only checked that the call failed. The empty, blank-line and missing-file cases all failed on main too, for the wrong reason, so they were characterization tests rather than regression tests, and the new unreadable-file guard had no coverage at all. expect_fail_message pins the message. With the -r guard removed the missing-file case now fails and shows the raw bash redirection error plus an unbound-variable error from set -u, which is what the guard prevents.
|
|
Two things I got wrong, both now pushed. The version was not bumped, so this PR could not have reached anyone.
and Three of the five new tests were not testing anything. which is the real behaviour the guard prevents: a raw redirection error leaked to the user, followed by a Correcting my own framing on reachability. The description mentions air-gapped systems and hand-generated checksums. 30/30 tests pass on bash 5.2. Happy to split the |
|
Closing this myself. I should have read CONTRIBUTING.md before opening it. The policy is explicit: this repo does not accept unsolicited contributions, a PR must be preceded by an issue and an assignment, and PRs that skip that are closed without review. This one skipped it, and so did the replacement I briefly opened as #418, which the bot closed for exactly that reason. That is my mistake twice over and I would rather withdraw than keep tripping the same rule. Two things are worth leaving in the thread in case they are useful to a maintainer. The bug is real. So a single-line checksum file with no trailing newline is rejected as empty. Separately, a missing or unreadable checksum path leaks a raw redirection error and then aborts on an unbound variable under No official release can trigger the first one. I am happy to open an issue for it and wait for assignment if that is welcome, but I will not open another PR here unless someone asks me to. Sorry for the noise. |
What's wrong
verify_checksum_file()decides whether the checksum file is empty from the exit status ofread:readreturns non-zero once it hits EOF without seeing a delimiter — even though it has already assigned the variables. So a single-line.sha256file that simply lacks a trailing newline aborts the install withChecksum file is empty, while the file in fact holds a perfectly good checksum that the very next line would have accepted.Reproduction
Scope, honestly
Releases published from this repo are not affected:
scripts/release-package.shwrites the file withsha256sum > …, which appends the newline.It bites the setups arcup deliberately supports through the
ARC_REPOandGITHUB_API_URLoverrides — mirrors, internal artifact stores, air-gapped relays and hand-generated checksums, where the trailing byte is routinely lost (printfwithout\n, object-store rewrites, copy-paste). With mainnet approaching, more operators will be pulling binaries through exactly those paths.The second cost is the diagnostic: the file is not empty, so the operator is sent to look at the wrong thing. A checksum failure during a node install is precisely where a misleading message is expensive.
The fix
Check the parsed value instead of the exit status, and report an unreadable file as unreadable rather than as empty:
Nothing is loosened. An empty file, a blank-line file and a bad hash all still fail — the hex/length regex and the filename check downstream are untouched.
Tests
Five cases added to
test_checksum_validationinarcup/test_arcup.sh, covering both the fix and the failure paths it must preserve:Red before, green after — the new tests were run against unpatched
arcup/arcupfirst:Full suite: 30/30 passing on
bash 5.2/ Linux.One thing I noticed but left alone
arcup/test_arcup.shis 800+ lines and is not run by any workflow in.github/workflows/, so this regression test will not actually guard anything until it is wired up. That felt like a separate decision (runner cost, matrix, whether you want the installer gating PRs), so I kept it out of this PR. Happy to send a small follow-up adding it toci.ymlif you want it.🤖 Generated with Claude Code
https://claude.ai/code/session_011ZRTcjFfRbYTTTCcF87aKC