Skip to content

fix(install): fix nightly digest extraction on macOS#331

Merged
BYK merged 1 commit intomainfrom
fix/install-nightly-macos
Mar 4, 2026
Merged

fix(install): fix nightly digest extraction on macOS#331
BYK merged 1 commit intomainfrom
fix/install-nightly-macos

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 4, 2026

Summary

The nightly install script fails on macOS with:

gunzip: (stdin): unexpected end of file

The OCI manifest digest extraction in Step 4 used sed 's/},{/}\\n{/g' to
split layers onto separate lines before awk extracted the digest. This had
two bugs:

  1. BSD sed (macOS) treats \\n as literal characters, not a newline —
    the manifest stays on one line and awk always finds the config digest
    (sha256:44136fa..., a 2-byte empty {} blob) instead of the binary.
  2. First-layer edge case: the first layer shares a line with the config
    block because the array starts with [{, not },{.

The result: downloading 2 bytes of {} instead of the ~23 MB compressed
binary.

Changes

Fix digest extraction (commit 1)

Replace the sed + awk pipeline with a single awk pass that tracks
the last-seen "digest" value and prints it when the target filename
matches in "org.opencontainers.image.title". No sed needed, works
on both GNU and BSD awk.

Add install error telemetry (commit 2)

Reports install failures to the CLI's existing Sentry project so we
catch issues like this automatically. Uses the same public write-only
DSN already baked into every CLI binary.

  • report_error() — builds a Sentry envelope and fires a background
    curl (fire-and-forget, 2s timeout, never blocks installation)
  • die() — replaces all echo + exit 1 patterns with error reporting
  • ERR trap — catches unexpected set -e / pipefail exits (e.g.,
    the gunzip failure that triggered this issue)
  • Tags: os, arch, channel, step, install.version
  • Opt-out: SENTRY_CLI_NO_TELEMETRY=1 (same as the CLI binary)

The install script's Step 4 used `sed 's/},{/}\n{/g'` to split OCI
manifest layers onto separate lines before extracting the blob digest
with awk. This had two bugs:

1. **macOS (BSD sed)**: `\n` in the replacement string is treated as
   a literal backslash + 'n', not a newline. The entire manifest stays
   on one line, so awk always matches the config's empty-JSON digest
   (`sha256:44136fa...`) instead of the layer digest. This affected
   ALL platforms when installing from macOS.

2. **First layer**: Even with GNU sed, the first layer
   (`darwin-arm64`) stays on the same line as the config block because
   the layers array starts with `[{`, not `},{`. The awk script finds
   the config digest first and exits. This affected darwin-arm64 on
   all platforms.

The result: downloading a 2-byte empty JSON blob (`{}`) instead of
the ~23 MB binary, causing `gunzip: (stdin): unexpected end of file`.

Fix: Replace the sed+awk pipeline with a single awk pass that tracks
the last-seen `"digest"` value and prints it when the target filename
is found in `"org.opencontainers.image.title"`. This works on both
GNU and BSD awk, requires no sed, and correctly handles all layer
positions.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Trace

Other

  • (api) Add --data/-d flag and auto-detect JSON body in fields by BYK in #320
  • (formatters) Render all terminal output as markdown by BYK in #297
  • (issue-list) Global limit with fair distribution, compound cursor, and richer progress by BYK in #306
  • (project) Add project create command by betegon in #237
  • (upgrade) Add binary delta patching via TRDIFF10/bsdiff by BYK in #327

Bug Fixes 🐛

Api

  • Use numeric project ID to avoid "not actively selected" error by betegon in #312
  • Use limit param for issues endpoint page size by BYK in #309
  • Auto-correct ':' to '=' in --field values with a warning by BYK in #302

Formatters

  • Expand streaming table to fill terminal width by betegon in #314
  • Fix HTML entities and escaped underscores in table output by betegon in #313

Install

  • Fix nightly digest extraction on macOS by BYK in #331
  • Fix nightly digest extraction on macOS by BYK in #331

Setup

  • Suppress agent skills and welcome messages on upgrade by BYK in #328
  • Suppress shell completion messages on upgrade by BYK in #326

Other

  • (ci) Generate JUnit XML to silence codecov-action warnings by BYK in #300
  • (nightly) Push to GHCR from artifacts dir so layer titles are bare filenames by BYK in #301
  • (region) Resolve DSN org prefix at resolution layer by BYK in #316
  • (test) Handle 0/-0 in getComparator anti-symmetry property test by BYK in #308
  • (trace-logs) Timestamp_precise is a number, not a string by BYK in #323

Internal Changes 🔧

Api

  • Upgrade @sentry/api to 0.21.0, remove raw HTTP pagination workarounds by BYK in #321
  • Wire listIssuesPaginated through @sentry/api SDK for type safety by BYK in #310

Other

  • (craft) Add sentry-release-registry target by BYK in #325

🤖 This preview updates automatically when you update the PR.

@BYK BYK marked this pull request as ready for review March 4, 2026 12:13
@BYK BYK merged commit 6d7a2bc into main Mar 4, 2026
19 checks passed
@BYK BYK deleted the fix/install-nightly-macos branch March 4, 2026 12:18
BYK added a commit that referenced this pull request Mar 4, 2026
## Summary

Add fire-and-forget error reporting to the install script via Sentry's
envelope API. Uses the CLI's existing public write-only DSN — no new
secrets or projects needed. This would have caught the macOS digest
extraction bug (#331) automatically.

## Changes

- `report_error()` — builds a minimal Sentry envelope and sends it via
  background `curl` (2s timeout, never blocks installation)
- `die()` — replaces all 11 `echo + exit 1` patterns with error
  reporting + exit
- `ERR` trap — catches unexpected `set -e` / `pipefail` exits like the
  gunzip pipeline failure that triggered #331
- UUID generation with fallback chain: `/proc` → `uuidgen` → `awk`
- Opt-out via `SENTRY_CLI_NO_TELEMETRY=1` (same as the CLI binary)

Each error event is tagged with `os`, `arch`, `channel`, `step`,
`install.version`, and bash version for quick triage.
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.

1 participant