Skip to content

fix(install): validate empty version requests and unreported installed versions - #2979

Closed
555aaditya wants to merge 3 commits into
morluto:mainfrom
555aaditya:fix/2580-installer-version-validation
Closed

555aaditya wants to merge 3 commits into
morluto:mainfrom
555aaditya:fix/2580-installer-version-validation

Conversation

@555aaditya

Copy link
Copy Markdown
Contributor

Summary

Fixes #2580.
Fixes #2581.

Two small version-identity defects in install.sh, both in how the installer reads a version string:

  1. fix(install): reject an explicitly empty version request #2580, empty explicit request. --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 --version was supplied and validates the value like any other explicit version. Omitting the option, or leaving REA_VERSION empty, still resolves the latest release.
  2. fix(install): diagnose an empty installed version as unreadable #2581, installed command reports no version. If the installed rea --version exited 0 but printed nothing (or only whitespace), the read "succeeded" with an empty string. The installer then reported installed 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.csv needs no new rows.

Problem and expected behavior

Invocation Before After
install.sh --version "" --dry-run exit 0, Version: <latest>, Dry run complete exit 1, version must be an exact semantic version., no plan printed, no npm call
install.sh --version not-a-version exit 1, semver error unchanged
install.sh --version 0.3.0 plan for 0.3.0 unchanged
install.sh (or REA_VERSION="") resolves latest unchanged
installed rea --version prints "" / " " installed version does not match 0.3.0. … the installed REA version could not be read. Reinstall the requested version, then retry.
installed rea --version prints 9.9.9 mismatch unchanged
installed rea --version exits 1 unreadable unchanged

Violated invariants:

  • docs/installation.md documents --version <semver>, and docs/user-visible-errors.csv (install.sh "version syntax") says explicit versions that aren't exact semantic versions are rejected.
  • The same CSV routes "installed rea executable cannot report its version" to the unreadable message, and uses the mismatch message only when a different version is reported.

Change and scope

  • fix(install): reject an explicitly empty version request #2580: a version_requested flag is set where --version is parsed. The existing validation branch now runs when the option was given or when REA_VERSION is 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.
  • fix(install): diagnose an empty installed version as unreadable #2581: the version read becomes 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 fail helper. The script still parses with bash -n.

Not included: an empty REA_VERSION keeps 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

  • Semantic owner and earliest changed stage: 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).
  • Contribution scope fit and linked maintainer decision: bug fix; not applicable.
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none. Bash constructs only, used in the same style as the surrounding script.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: an empty explicit request now fails before any release lookup, install plan, or npm call. Nothing else about what gets installed changes.
  • Generated metadata, package, or installation impact: installer behaviour only for the two edge cases above. No package metadata change.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

(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:

  • fix(install): reject an explicitly empty version request #2580: "" added to the existing rejects malformed semantic versions before invoking npm cases. It asserts empty stdout (no plan), the exact semver error, and no npm invocation.
  • fix(install): reject an explicitly empty version request #2580 control: new resolves the latest release when REA_VERSION is empty. An empty environment variable still selects the latest tag (Version: 0.3.0).
  • fix(install): diagnose an empty installed version as unreadable #2581: new installer installed version identity block, reports an installed command without a version as unreadable for "" and " ". It asserts the exact unreadable-version message.
  • The existing unreadable installed version (nonzero exit) and version mismatch (9.9.9) table rows remain the controls for the other two routes.
  • Fixture: the fake rea now 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 to 0.3.0, and no existing test sets it to an empty value.
  • I put the installed-version cases in their own small describe, rather than as two more rows in the curl installer scenarios table, to keep that callback under the max-lines-per-function limit.

Base reproduction: with only the install.sh change 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 | bash install. 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 current origin/main:

  • npx vitest run tests/boundary/filesystem/installScript.test.ts: with the install.sh fix 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 --check and npx oxlint on the changed files: clean.
  • I didn't run shellcheck; it isn't installed locally.

Compatibility, safety, and release

  • Breaking changes or migration steps: none for valid use. Scripts that pass --version "" expecting "latest" must drop the option, or set REA_VERSION to empty or leave it unset. That invocation previously contradicted the documented --version <semver> contract.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the installer now fails earlier (before any network request) for an empty explicit version, and keeps failing closed on an unreadable installed version. No new commands, paths, or inputs.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

…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
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-13T18:38:59.473531Z 11369c9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low impact] The test-only changes appear safe to merge.

Summary

This PR expands tests for existing installer behavior:

  • Installer tests now cover blank installed-version reports.
  • Installer tests distinguish an empty version request from an empty setting.

No actionable correctness, security, or repository-rule issues were found. The current diff changes tests only. GitHub access was unavailable, so whether another PR supersedes this one could not be checked.

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@morluto morluto added area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working labels Oct 14, 2026
morluto added a commit that referenced this pull request Oct 14, 2026
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.
@kaoru0822-kitauji kaoru0822-kitauji added the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
# Conflicts:
#	install.sh
#	tests/boundary/filesystem/installScript.test.ts
@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

CI-fix track: the Windows lane failure (inspection conformance probe.mjs retry, "Missing expected exception") isn't from this PR; unrelated PRs failed it the same way. I merged main to clear the conflicts. Main already took the equivalent install.sh change in ec56c1d (explicit --version validation and the empty installed-version check), so install.sh now matches main. What's left is this PR's added coverage: a whitespace-only reported version, an explicitly empty requested version, and an empty REA_VERSION resolving the latest release. All 38 installer boundary tests pass against main's script, and check:fast is clean. Main is currently red for unrelated reasons; #3080 fixes that.

@kaoru0822-kitauji kaoru0822-kitauji removed the ci-fix-wip Claimed by the CI-fix track label Oct 14, 2026
@555aaditya

Copy link
Copy Markdown
Contributor Author

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.

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in ec56c1d. The code is in install.sh, and rejects an explicitly empty version instead of selecting latest covers it. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@555aaditya

Copy link
Copy Markdown
Contributor Author

Thanks for checking! Confirmed: main now covers this. ec56c1da0 has the install.sh change, and the explicit-empty --version and empty installed-version cases are tested on main. The only cases left here are a whitespace-only installed version (same code path as the empty case) and an empty REA_VERSION control, so I'm closing this as superseded. Thanks @morluto and @kaoru0822-kitauji for integrating it.

@555aaditya 555aaditya closed this Oct 14, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: setup Setup, packaging, upgrade, install, Doctor, and client registration bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(install): diagnose an empty installed version as unreadable fix(install): reject an explicitly empty version request

4 participants