Skip to content

fix: drop stale target version from root upgrade prompt - #2100

Open
dc-bytedance wants to merge 1 commit into
mainfrom
fix/upgrade-prompt-drop-version
Open

fix: drop stale target version from root upgrade prompt#2100
dc-bytedance wants to merge 1 commit into
mainfrom
fix/upgrade-prompt-drop-version

Conversation

@dc-bytedance

@dc-bytedance dc-bytedance commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

The interactive upgrade prompt for bare lark-cli named a target version that
could differ from the version actually installed. The prompt's version came from
the on-disk cache read by update.CheckCached, which has no expiry — the 24h
cacheTTL only throttles RefreshCache, and a failed refresh leaves the old
value in place, so on an offline or registry-unreachable machine the cached
latest_version can persist indefinitely. The version actually installed is
resolved live: pressing y runs the update subcommand, which re-queries the
npm registry and pins that version. Any release published between the cache write
and the keypress made the prompt wrong.

The prompt now names only the current version, so everything it states is locally
verifiable. The update subcommand still prints
Updating lark-cli <cur> -> <latest> via <pm> ... before installing, so the user
still sees the real target version before anything is written.

Changes

  • cmd/root_upgrade.go: drop info.Latest from the prompt; the text is now
    A newer lark-cli is available (current <version>). Upgrade now? [y/N]: .
    Added a comment recording why no target version is named, and that the upgrade
    must keep going through the update subcommand — calling RunNpmInstall
    directly would remove the only place the real target version is shown.
  • cmd/root_upgrade_test.go: strengthen TestOfferRootUpgrade. The existing
    Contains(stderr, "available") assertion holds for both the old and the new
    text, so it could not detect this change or a regression. On prompting cases the
    test now asserts stderr does not contain the cached target version and does
    contain the current version.

Not touched: the JSON _notice channel (update.Message()), cacheTTL,
CheckCached / RefreshCache, and everything under cmd/update/.

Test Plan

  • go test ./cmd/ -run TestOfferRootUpgrade -v — 12/12 subtests pass. Verified
    red-green: with the new assertions but the old text, the 5 prompting subtests
    fail with prompt must not name the cached target version "2.0.0".
  • go test ./cmd/ -run 'TestReadYes|TestIsBareRootInvocation|TestInstallRootUpgradePrompt|TestRunRootUpgradeDispatchesToUpdate' — pass.
  • go build ./..., go vet, unit and integration tests — pass.
  • golangci-lint run --new-from-rev=origin/main — 0 issues.
  • Manual, under a real TTY (a separate pty per stream, built with a clean release
    version so isRelease() does not suppress the prompt): stderr is exactly
    A newer lark-cli is available (current 1.0.79). Upgrade now? [y/N]: — 68
    bytes, no trailing newline, no target version. All four gates behave as before:
    silent when any stream is not a TTY, silent under
    LARKSUITE_CLI_NO_UPDATE_NOTIFIER=1, silent under CI=true, no prompt when a
    flag token is present, and Enter is treated as No.

Related Issues

None.

Summary by CodeRabbit

  • Bug Fixes
    • Updated the root upgrade prompt to display the currently installed version without showing a potentially outdated target version.
    • Preserved the existing confirmation and upgrade flow.

@dc-bytedance dc-bytedance added the bugfix Bug fixes label Jul 29, 2026
@github-actions github-actions Bot added the size/L Large or sensitive change across domains or core paths label Jul 29, 2026
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6eaf1d6a-7d7d-40b1-aa48-85a6ff214593

📥 Commits

Reviewing files that changed from the base of the PR and between 7988515 and 291fd85.

📒 Files selected for processing (2)
  • cmd/root_upgrade.go
  • cmd/root_upgrade_test.go

📝 Walkthrough

Walkthrough

The root upgrade prompt no longer displays the cached latest version. It displays the current version, while tests verify the cached target is absent and the current version is present.

Changes

Root upgrade prompt

Layer / File(s) Summary
Prompt target display and validation
cmd/root_upgrade.go, cmd/root_upgrade_test.go
The prompt omits info.Latest, displays info.Current, and tests assert that cached target-version text is absent while the installed version appears.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • larksuite/cli#1498: Introduced the root upgrade prompt and its associated wiring and tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: removing the stale target version from the root upgrade prompt.
Description check ✅ Passed The description follows the template and includes summary, changes, test plan, and related issues with sufficient detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/upgrade-prompt-drop-version

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.19%. Comparing base (c7adff7) to head (291fd85).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2100      +/-   ##
==========================================
+ Coverage   75.18%   75.19%   +0.01%     
==========================================
  Files         913      914       +1     
  Lines       96656    96781     +125     
==========================================
+ Hits        72671    72776     +105     
- Misses      18395    18407      +12     
- Partials     5590     5598       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@291fd857c3277df165220f008a3b35f3726b55e5

🧩 Skill update

npx skills add larksuite/cli#fix/upgrade-prompt-drop-version -y -g

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

Labels

bugfix Bug fixes size/L Large or sensitive change across domains or core paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant