Repository navigation
fix(install): validate empty version requests and unreported installed versions - #2979
555aaditya wants to merge 3 commits into
Conversation
…d versions An explicit `--version ""` was treated as an omitted option, so the installer silently resolved and installed the latest release instead of rejecting the request. Record that --version was supplied and validate its value like any other explicit version; omitting the option, or an empty REA_VERSION, still resolves the latest release. When the installed command exited successfully but printed no version (or only whitespace), the installer reported a mismatch against an empty version. Treat empty output as unreadable so it takes the documented "could not be read" route; a different reported version still fails as a mismatch. Fixes morluto#2580 Fixes morluto#2581
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Keep layered environment choices, current byte-exact recovery snapshots, and package-manager failure details. Report pinned package drift without claiming runner resolution. Retain failed Linux installer cleanup for host-owned retry while preserving the install outcome. Reviewed fixes include #2632, #2769, #2783, #2959, #2979, #2983, #2995, #3009, and #2559. Validation: 98 focused setup/registration tests passed; 45 Linux installer tests passed. Real Linux package installation remains unverified.
# Conflicts: # install.sh # tests/boundary/filesystem/installScript.test.ts
|
CI-fix track: the Windows lane failure (inspection conformance |
|
Thanks @kaoru0822-kitauji for merging main and for the CI triage. Agreed: with ec56c1d carrying the install.sh change, this PR is now regression coverage only. I merged the latest main again in e41c436; all 38 installer tests pass, and CI is green. I've updated the description to match the test-only scope. |
|
Heads up: main already has this change in ec56c1d. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks for checking! Confirmed: main now covers this. |
|
Thanks @555aaditya for catching that an empty version request could silently select the latest release. Main now rejects that input and covers it at the installer boundary (main). |
Summary
Fixes #2580.
Fixes #2581.
Two small version-identity defects in
install.sh, both in how the installer reads a version string:--version ""was indistinguishable from omitting the option, because validation was gated on[ -n "$version" ]. The installer silently resolved the latest release and installed it, instead of rejecting a request that isn't a semantic version. It now records that--versionwas supplied and validates the value like any other explicit version. Omitting the option, or leavingREA_VERSIONempty, still resolves the latest release.rea --versionexited 0 but printed nothing (or only whitespace), the read "succeeded" with an empty string. The installer then reportedinstalled version does not match 0.3.0, the mismatch diagnostic with a blank actual value. Empty output now takes the documented unreadable-version route instead. A different non-empty version still fails as a mismatch.Both fixes keep a single validation point and reuse the existing messages, so
docs/user-visible-errors.csvneeds no new rows.Problem and expected behavior
install.sh --version "" --dry-runVersion: <latest>,Dry run completeversion must be an exact semantic version., no plan printed, no npm callinstall.sh --version not-a-versioninstall.sh --version 0.3.0install.sh(orREA_VERSION="")rea --versionprints""/" "installed version does not match 0.3.0. …the installed REA version could not be read. Reinstall the requested version, then retry.rea --versionprints9.9.9rea --versionexits 1Violated invariants:
docs/installation.mddocuments--version <semver>, anddocs/user-visible-errors.csv(install.sh "version syntax") says explicit versions that aren't exact semantic versions are rejected.Change and scope
version_requestedflag is set where--versionis parsed. The existing validation branch now runs when the option was given or whenREA_VERSIONis non-empty. I chose this over a separate empty-value check in the argument parser so that there is still exactly one place deciding whether an explicit version is valid, with one message.installed_version="$(…)" && [ -n "$installed_version" ] || fail "…could not be read…". A nonzero exit (the existing route) and empty output now share the one unreadable-version failure, and the following mismatch check only ever sees a non-empty version.Both changes stay inside the truncation-guard brace group and use the existing
failhelper. The script still parses withbash -n.Not included: an empty
REA_VERSIONkeeps meaning "not set", which is the existing behaviour and is preserved by #2580's restoration check.Contribution scope: an ordinary fix within existing installer behaviour, so a maintainer scope decision is not applicable.
Contract and boundary impact
install.sh, in option parsing and version validation (fix(install): reject an explicitly empty version request #2580), and the post-install identity read (fix(install): diagnose an empty installed version as unreadable #2581).Expected effects:
(No analysis-target interaction. The installer's existing network and npm behaviour is unchanged, except that an empty explicit version now stops before reaching either.)
Evidence and regression coverage
All in
tests/boundary/filesystem/installScript.test.ts, using the existing fake curl, npm and rea fixture:""added to the existingrejects malformed semantic versions before invoking npmcases. It asserts empty stdout (no plan), the exact semver error, and no npm invocation.resolves the latest release when REA_VERSION is empty. An empty environment variable still selects the latest tag (Version: 0.3.0).installer installed version identityblock,reports an installed command without a version as unreadablefor""and" ". It asserts the exact unreadable-version message.unreadable installed version(nonzero exit) andversion mismatch(9.9.9) table rows remain the controls for the other two routes.reanow prints${FAKE_REA_VERSION-0.3.0}instead of${FAKE_REA_VERSION:-0.3.0}, so a test can request a genuinely empty version. When unset it still defaults to0.3.0, and no existing test sets it to an empty value.describe, rather than as two more rows in thecurl installer scenariostable, to keep that callback under themax-lines-per-functionlimit.Base reproduction: with only the
install.shchange reverted, the three new cases fail (3 failed | 34 passed). With it, all 37 pass.Remaining proof gaps: verified with the repo's fake-tool fixture, not a real
curl | bashinstall. Linux behaviour is covered only through the same fixture (FAKE_PLATFORM), via CI.Validation performed
All run on macOS (arm64), Bash at
/bin/bash, Node 26.5.0, npm 11.17.0, with locked dependencies, rebased on currentorigin/main:npx vitest run tests/boundary/filesystem/installScript.test.ts: with theinstall.shfix reverted, 3 failed (the new cases) and 34 passed. With the fix, 37 passed.bash -n install.sh: OK.npm run check:fast(typecheck + lint + module boundaries): passed, also via the pre-push hook.npx oxfmt --checkandnpx oxlinton the changed files: clean.shellcheck; it isn't installed locally.Compatibility, safety, and release
--version ""expecting "latest" must drop the option, or setREA_VERSIONto empty or leave it unset. That invocation previously contradicted the documented--version <semver>contract.Before merge
type(scope): outcome.