Repository navigation
fix(cli): Make installer failures actionable - #2286
Merged
Merged
Conversation
Fixes CLI-BJ. The installer's ERR trap reported only "Unexpected failure at line N", and bash 3.2 reports the closing `fi` of the enclosing block, so the line often pointed nowhere. A failure inside a function exited with no message and no report, because the ERR trap was not inherited. - Enable errtrace and report the failing command's unexpanded source text, its function, and its exit status. The text has no expanded paths or values. - Stop report_error from tripping the trap on its own failures. - Give a failed gunzip, usually a full temporary directory, a clear message and its own `unpack` step. - Read release registry metadata from curl's stdout instead of a temp file, which bash could not read on some Windows shells. Co-Authored-By: bete <28983162+betegon@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
The redirected nightly path still piped curl into gunzip, so a full temp directory there hit the generic trap. Download to the blob file first and unpack it like the other paths.
Retry transient network errors with curl's backoff, download a broken or corrupt archive once more, stage the download in the install directory when the temp directory is full or unwritable, and authenticate the GitHub releases fallback with GITHUB_TOKEN or GH_TOKEN, retrying rate limits. install.ps1 also downloads once more on a checksum mismatch, since both installers share the scenario table. Refs CLI-BJ Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
CodeQL flagged the api.github.com substring check.
Contributor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6e272dc. Configure here.
…e setup Nightly GHCR fetches now go through write_staged, with the response headers read from stdout instead of a temp file, and a write failure dies with the no-room message. The install-dir PATH check ignores one trailing slash, and case on macOS and Windows, like samePath, so the staged binary lands where setup renames it.
BYK
approved these changes
Nov 16, 2026
7 tasks done
This branch was previously deployed
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.

Fixes CLI-BJ (https://sentry.sentry.io/issues/7314884676/).
CLI-BJ collects every
Unexpected failure at line Nevent from the bash installer's ERR trap. This PR first makes the installer recover from the failures behind those events. It dies with a clearer message only when the user has to act, and it keeps reporting the failures that are left.Prevention and recovery
--retry 3 --retry-connrefused --retry-max-time 60. curl retries timeouts, refused connections, 408, 429, and 5xx with exponential backoff. The binary needs glibc 2.28 or macOS 11, whose curl (7.61, 7.64) has--retry-connrefused(7.52) but not--retry-all-errors(7.71), so--retry-all-errorsis not used. The 2s--max-timeprobe inreport_erroris unchanged.download_verifieddownloads once more when the transfer breaks, the SHA-256 does not match, orgunzip -trejects the archive. If the.gzis missing or still unusable, it falls back to the raw binary as before. A checksum mismatch on both tries is still fatal.install.ps1also downloads once more on a mismatch, because both installers share the scenario table.$TMPDIRfails (curl exit 23, or gunzip cannot write), the installer stages the file in the directory setup installs into. This covers stable and nightly downloads. It resolves that directory the same way asdetermineInstallDirinsrc/lib/binary.ts, and matches PATH entries likesamePath: one trailing slash is ignored, and on macOS and Windows so is case. The binary takes setup's own temp name,<install-dir>/sentry.download, sosentry cli setup --installrenames it into place atomically instead of copying it. The nightly GHCR fetch reads its response headers from stdout, so only the body needs disk space. Partial files are removed. The installer prints "There is not enough room to stage sentry ..." only when both directories fail.Authorization: Bearer $GITHUB_TOKEN(orGH_TOKEN) if one is set. The header goes to curl on stdin (-H @-), so the token is not in the process list. Because$BASH_COMMANDis unexpanded source text, an error report shows${token}, not the value. Responses with 403/429 are retried after 2s and 4s. Without a token, the installer suggests settingGITHUB_TOKEN. GitHub Actions does not exportGITHUB_TOKENautomatically, so workflows needenv: GITHUB_TOKEN: ${{ github.token }}.-w '\n%{http_code}') instead of a temp file that bash sometimes could not read. Why bash could not read the file is not confirmed.Reporting
set -E, and the trap goes throughon_unexpected_failure. It reports the line, the function, the exit status, and$BASH_COMMAND, truncated to 200 chars.$BASH_COMMANDis unexpanded source text ("$tmp_binary", not the path), so reports contain no user paths, env values, or tokens. No new tags or fields; only the message text changes. Before this, a failure inside a function exited 1 with no message and no report. On bash 3.2, the line number pointed at the closingfiof the enclosing block (the 1 event at line 442).report_errorrunstrap - ERRin its subshell, so an offline ingest cannot set off the trap again.checksum_matches. It runs as a condition, where the ERR trap is off, and it dies with achecksumstep.The older groups (no events since Oct 1, pre-Toolkit script ≤0.45.0) are already fixed on main: ~25.9k events from the GitHub
releases/latestlookup (lines 281/280/304), 101 fromsentry cli setupexits (lines 333/332), and 128 from the raw curl with no|| die(lines 302/304/394/398/400).Before / after
Real runs of the main installer and this branch in a sandbox. curl, gunzip, and the network are stubbed per case;
<install-dir>is a placeholder.Full temp directory during unpack:
Release registry returns 503 twice, then 200 (real curl 8.x against a local server):
Connection reset on the first
.gzand the first raw download:Truncated first
.gz(checksum mismatch):Registry down, GitHub returns 403 once:
Unexpected failure that is still reported (
chmodfails):via @betegon, @BYK.
--
View Session [Sentry]