Skip to content

Fix: vfox upgrade unable to detect current version#556

Merged
aooohan merged 2 commits intomainfrom
copilot/fix-vfox-upgrade-issue
Oct 10, 2025
Merged

Fix: vfox upgrade unable to detect current version#556
aooohan merged 2 commits intomainfrom
copilot/fix-vfox-upgrade-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Oct 10, 2025

Problem

When running vfox upgrade, the command fails to detect the current version, displaying only v instead of v0.9.1:

PS C:\Users\Cloud> vfox upgrade
Current version:  v
Latest available: v0.9.1

This issue occurs on Windows with version 0.9.1 and affects the upgrade command's ability to compare versions properly.

Root Cause

The upgradeCmd function in cmd/commands/upgrade.go was attempting to access the version from cmd.Version, where cmd is the upgrade subcommand's *cli.Command struct. However, in the urfave/cli/v3 framework:

  • The Version field is only populated on the root application command
  • Subcommands do not inherit the Version field from their parent
  • Therefore, cmd.Version returns an empty string for the upgrade subcommand

Solution

Changed line 119 in cmd/commands/upgrade.go to use internal.RuntimeVersion directly:

// Before
currVersion := fmt.Sprintf("v%s", cmd.Version)

// After
currVersion := fmt.Sprintf("v%s", internal.RuntimeVersion)

This ensures the current version is always correctly retrieved from the centralized version constant defined in internal/version.go, which is the same source used to set the version on the root command.

Testing

  • ✅ Code builds successfully
  • ✅ All existing tests pass
  • ✅ The fix is consistent with how internal.RuntimeVersion is used throughout the codebase
  • ✅ Minimal change (single line) with no breaking changes

After this fix, vfox upgrade will correctly display:

Current version:  v0.9.1
Latest available: v0.9.1

Fixes: Issue describing vfox upgrade cannot detect current version

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://version-fox.github.io:443/vfox-plugins/index.json
    • Triggering command: /tmp/go-build811042808/b363/http.test -test.testlogfile=/tmp/go-build811042808/b363/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true (http block)
  • version-fox.github.io
    • Triggering command: /tmp/go-build811042808/b363/http.test -test.testlogfile=/tmp/go-build811042808/b363/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.short=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG]: vfox upgrade 无法识别当前版本</issue_title>
<issue_description>Version
0.9.1

OS
Windows

Describe the bug
vfox upgrade 无法识别当前版本

Screenshots[optional]
Image
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #554


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: aooohan <40265686+aooohan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix vfox upgrade not recognizing current version Fix: vfox upgrade unable to detect current version Oct 10, 2025
Copilot AI requested a review from aooohan October 10, 2025 07:44
@aooohan
Copy link
Copy Markdown
Member

aooohan commented Oct 10, 2025

@copilot The version number has been correctly set in the newCmd method, why isn't it displayed?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Oct 10, 2025

@copilot The version number has been correctly set in the newCmd method, why isn't it displayed?

The version is correctly set on the root command in newCmd (line 64: app.Version = version), but the issue is that when upgradeCmd runs, the cmd parameter refers to the upgrade subcommand, not the root command.

In urfave/cli/v3, the Version field is only set on the root command and is not automatically inherited by subcommands. So when we tried to access cmd.Version from within the upgrade subcommand, it returned an empty string.

The fix uses internal.RuntimeVersion directly, which is the same source used to set the root command's version. This is consistent with how version information is accessed throughout the codebase (e.g., in internal/manager.go for plugin compatibility checks).

Alternatively, we could use cmd.Root().Version to access the parent's version field, but using internal.RuntimeVersion is simpler and more direct.

Commit: 1e6405b

@aooohan aooohan marked this pull request as ready for review October 10, 2025 07:57
Copilot AI review requested due to automatic review settings October 10, 2025 07:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where the vfox upgrade command was unable to detect the current version, displaying only v instead of the actual version like v0.9.1. The issue was caused by the upgrade subcommand attempting to access the version from cmd.Version, which is only populated on the root application command in urfave/cli/v3.

  • Fixed version detection by using internal.RuntimeVersion instead of cmd.Version

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 21.27%. Comparing base (2e5db6c) to head (1e6405b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/commands/upgrade.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #556   +/-   ##
=======================================
  Coverage   21.27%   21.27%           
=======================================
  Files          71       71           
  Lines        5842     5842           
=======================================
  Hits         1243     1243           
  Misses       4502     4502           
  Partials       97       97           

☔ View full report in Codecov by Sentry.
📢 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.

@aooohan aooohan merged commit 7f31e65 into main Oct 10, 2025
5 checks passed
@aooohan aooohan deleted the copilot/fix-vfox-upgrade-issue branch October 10, 2025 08:13
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.

[BUG]: vfox upgrade 无法识别当前版本

3 participants