Skip to content

fix: sc upgrade crashes with syntax error for existing installs#342

Merged
Cre-eD merged 2 commits into
mainfrom
fix/sc-sh-version-embed-v2
Jun 25, 2026
Merged

fix: sc upgrade crashes with syntax error for existing installs#342
Cre-eD merged 2 commits into
mainfrom
fix/sc-sh-version-embed-v2

Conversation

@Cre-eD

@Cre-eD Cre-eD commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Root cause

push.yaml line 637 used a single-quoted sed script:

sed -i -e 's/VERSION="0\.0\.0"/VERSION="${VERSION}"/g' ...

Single quotes suppress shell expansion, so the literal string ${VERSION} was written into every distributed sc.sh. At runtime (user's shell), $VERSION is unset → VERSION="". Then:

semver_compare "" "2026.x.y"
  → compareNumber "" "2026"
  → $((2026 - ))   ← syntax error

Broke everyone doing sc upgrade or curl … | bash who already had sc installed.

Changes

push.yaml — switch to double-quoted sed so the CI env var expands at build time:

sed -i -e "s/VERSION=\"0\\.0\\.0\"/VERSION=\"${VERSION}\"/" ...

sc.sh — two belt-and-suspenders guards so the script never crashes even if VERSION is empty for any other reason:

  • compareNumber: handle one-empty-arg cases (was only guarding both-empty)
  • version-compare block: skip semver_compare when VERSION is empty; an empty target version means "fetch latest", so the default VERSION_COMPARE="1" is correct

Test plan

Closes #341

…mber empty args

push.yaml line 637 used single-quoted sed, so `${VERSION}` was written
literally into sc.sh instead of being expanded to the actual release tag.
Result: every downloaded sc.sh had `VERSION="${VERSION}"` → empty at
runtime → `semver_compare "" "$CURRENT"` → `$((2026 - ))` syntax error
for any user who already had sc installed (sc upgrade / curl | bash).

Root-cause fix (push.yaml): switch to double-quoted sed so the CI env var
expands before the sed script is built.

Belt-and-suspenders fix (sc.sh):
- compareNumber: guard one-empty-arg cases (previously only both-empty)
- version-compare block: skip semver_compare when VERSION is empty rather
  than crashing; empty VERSION = no specific target = always fetch latest

Signed-off-by: Dmitrii Creed <creeed22@gmail.com>
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Semgrep Scan Results

Repository: api | Commit: fd62ba2

Check Status Details
⚠️ Semgrep Warning 1 warning(s), 1 total

Scanned at 2026-06-25 07:56 UTC

@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown

Security Scan Results

Repository: api | Commit: fd62ba2

Check Status Details
✅ Secret Scan Pass No secrets detected
✅ Dependencies (Trivy) Pass 0 total (no critical/high)
✅ Dependencies (Grype) Pass 0 total (no critical/high)
📦 SBOM Generated 522 components (CycloneDX)

Scanned at 2026-06-25 07:56 UTC

@github-actions

Copy link
Copy Markdown

📊 Statement coverage

Measured on the documented included set (see docs/TESTING.md → Coverage scope). Observe-only — no regression gate is enforced yet.

Scope This PR main baseline Δ
Included set (Gold-tier denominator) 90.3% 90.3% +0.0 pp
Full set (whole repo, transparency) 27.7% 27.7% +0.0 pp

Baseline: main @ 4bdf2b3

@Cre-eD
Cre-eD merged commit 9145b8d into main Jun 25, 2026
23 checks passed
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.

3 participants