Files
Jon Chery 61c97c847c fix(P1): recompute TARBALL after fallback version walk (REQ-132)
The fallback walk (REQ-098) reassigns VERSION from the requested
release to the nearest older release carrying a binary asset, but
never recomputed TARBALL (set once at line 106 from the requested
version). The stale tarball name then flowed into:

  - grep -F "$TARBALL" SHA256SUMS  -> matched nothing (the fallback
    release's SHA256SUMS only lists the fallback tarball)
  - sha256sum -c -                 -> empty stdin -> "no properly
    formatted checksum lines found" -> REQ-132 refusal
  - tar -xzf "${TMPDIR}/${TARBALL}" -> would look for the wrong
    filename (download saved under the stale name too)

User-visible symptom (v0.14.2 latest had no asset, fell back to
v0.12.18):

  install: verifying checksum...
  sha256sum: 'standard input': no properly formatted checksum lines found
  install: error: checksum verification failed (REQ-132); refusing to install

Fix: recompute TARBALL immediately after VERSION is reassigned in the
fallback branch, so download/grep/sha256sum/tar all reference the
fallback version's tarball. ASSET_URL and SHA256SUMS_URL were already
correct (derived from the API/ASSET_URL); TARBALL was the only stale
variable.

Reproduced the exact error before the fix; confirmed end-to-end
install succeeds after (orca-v0.12.18-linux-amd64.tar.gz: OK ->
extracting -> installed). Added a bats regression test pinning
--version v0.14.2 and asserting the dry-run "would install" line
references the fallback version (not the stale pinned one).

---ci---
project: orca
phase: 1
milestone: v0.15
status: execute
decisions:
  - id: D-001
    decision: Recompute TARBALL in the fallback branch immediately
      after VERSION is reassigned, so grep/sha256sum/tar use the
      fallback version's filename instead of the stale requested
      version's.
    rationale: Reproduced the exact user error ("no properly formatted
      checksum lines found") by running grep -F "$TARBALL" SHA256SUMS
      | sha256sum -c with a stale v0.14.2 tarball name against v0.12.18
      SHA256SUMS. TARBALL is the only stale variable: ASSET_URL and
      VERSION are correctly updated from API output, and SHA256SUMS_URL
      derives from ASSET_URL. Single-line fix, minimal blast radius,
      preserves the working non-fallback path.
    confidence: 0.96
    alternatives:
      - lazy TARBALL via a function (over-engineering for one stale
        assignment)
      - move TARBALL= assignment past the fallback block (breaks
        find_asset_url which needs the requested version's name
        pre-walk)
lessons:
  - When a fallback/walk mutates one variable (VERSION), audit every
    variable derived from it (TARBALL) for the same mutation. The
    user-facing info line at 167 constructed the name inline and
    looked correct, masking that the variable itself was stale.
---/ci---
2026-08-10 21:18:24 +00:00
..

Bash Testing Policy (grill C-15)

Every bash script under scripts/ MUST have at least one bats test covering the happy path and one covering the failure path. This is the compensating control for bash being exempt from the Go coverage gate (D-186).

Framework

  • batsbats scripts/tests/*.bash runs all bash tests.
  • shellcheckshellcheck scripts/*.sh scripts/lib/*.sh scripts/tests/*.bash static analysis.
  • shfmtshfmt -d scripts/ formatting check (optional; skip if not installed).

Install (if missing)

# bats
npm install -g bats    # or: git clone https://github.com/bats-core/bats-core.git && ./bats-core/install.sh /usr/local
# shellcheck
apt-get install -y shellcheck
# shfmt (optional)
mvdan.cc/sh (go install mvdan.cc/sh/v3/cmd/shfmt@latest)

Running

make test-bash   # runs bats (skips gracefully if bats missing)
make lint-bash   # runs shellcheck + shfmt (skips gracefully if missing)
make test        # runs both Go + bash tests
make lint        # runs both Go + bash lint

Test file convention

  • Test files live in scripts/tests/<script-name>_test.bash.
  • Source load test_helper at the top of every test file.
  • Happy path: @test "<script> happy path" { ... }
  • Failure path: @test "<script> failure path" { ... }
  • Use run <command> + assert_status/assert_contains/assert_not_contains from test_helper.