Repository navigation
fix(cli): fail updates when installer download fails - #1485
Open
vicmcorrea wants to merge 2 commits into
Open
vicmcorrea wants to merge 2 commits into
vicmcorrea wants to merge 2 commits into
Conversation
Lorenzobattistela
requested changes
Oct 11, 2026
Lorenzobattistela
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @vicmcorrea, the fix is right: refused, 404 and truncated downloads now exit with curl's code, and a partial script no longer runs. The new ping check fails on main and passes here.
It's more code than this needs, though (+140 tokens in main.ts, a temp dir, an fd and two try/finally blocks). It also loses a few things main had: a missing curl now exits 1 with no message, a signalled installer exits 1 instead of 128+n, and Ctrl-C during the install leaves the temp dir behind. Keeping the shell and only running sh once curl has finished (s=$(curl -fsSL ...) && printf '%s\n' "$s" | sh) fixes it in a line, with no temp file. Could you simplify it that way?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and fix
bend updatereturns 0 when curl fails because the lastshincurl | shsucceeds on empty input. A failed partial download can also execute its prefix.Capture the installer in a shell variable and invoke
shonly after curl succeeds:s=$(curl -fsSL ...) && printf '%s\n' "$s" | sh. This follows the maintainer's requested simplification, replacing the previous temporary-file implementation. The displayed command uses the same guarded download. Shell diagnostics and installer signal exit statuses are preserved.Fixes #1481.
Blast radius
Only two files change.
bend2/main.tschanges the sole-argumentupdatecommand.gates/ping.tsadds a failed-download assertion beside the existing successful update check and updates that check's expected command text. Regression coverage stays in the existing installed-CLI gate, following the CLI exit-status precedent in #1214.The final change uses no temporary files or descriptors. Language/compiler/runtime sources, installer content, permanent caps and gate policy are unchanged.
Regression evidence
Source and rebuilt compiled-CLI probes show the original implementation returns 0 for refused connections, HTTP 404 and truncated responses. The revision returns curl's 7, 22 and 18 respectively, and never executes the failed partial script. Controlled curl failure 23 also propagates. Successful scripts return 0; installer failure 17 and signal status 143 remain observable. Missing curl now reports the shell diagnostic and returns 127.
Checks
gates/ping.tsexercised against rebuilt CLIs. They pass on this revision and on current main (d71f42e) with the PR patch applied; the new failure assertion fails on the original implementation.git diff --check: passed.8a76db3.Validation limits
Full
gates/ping.tsskipped because the sibling site repository is unavailable. Harmless local installer fixtures do not qualify the real archive/install/hub flow. Local tests ran on macOS arm64 with Bun 1.3.11 and curl 8.7.1; Linux/WSL, Windows, CI Bun 1.4.0 and cluster gates were not run locally.TypeScript 7.0.2 with
bend2/pack/tsconfig.jsonreports the same 12 diagnostics on the original base and this revision, including existing checker/elaborator/docs errors and missing optionalcanvastypes. Typecheck is not clean; no new diagnostics were introduced.The shell buffers the complete text installer before execution. Command substitution removes trailing newlines;
printfadds one before passing the text tosh.