Skip to content

feat: warn when src-cli is older than the instance's recommended version#1347

Open
Montana wants to merge 1 commit into
sourcegraph:mainfrom
Montana:version-check-warn
Open

feat: warn when src-cli is older than the instance's recommended version#1347
Montana wants to merge 1 commit into
sourcegraph:mainfrom
Montana:version-check-warn

Conversation

@Montana

@Montana Montana commented Jul 1, 2026

Copy link
Copy Markdown

Hey @burmudar,

This is superseded by my last PR. I've consolidated the implementation, the main() wiring, and these tests into a single PR that builds. Splitting the tests out on their own was my mistake; on its own that branch didn't compile. I've run the go checks locally (build and tests on 1.26.4) and they pass without error.

What's in it:

  • The check is invoked from main() via maybeWarnVersion, and reuses the existing getRecommendedVersion helper against /.api/src-cli/version rather than duplicating the request.
  • Fail-open on everything. Missing config, network errors, an unreachable instance, or an unparseable version all result in no warning, never an error.
  • 3s timeout so it never noticeably delays a command, and it writes only to stderr so --json output is unaffected.
  • Skips version, help, and no-arg invocations, dev builds (version.BuildTag == version.DefaultBuildTag), and any run with SRC_SKIP_VERSION_CHECK set.
  • Comparison is major/minor/patch only, so prereleases don't trigger spurious warnings.
  • Unit tests cover parseVersion, isOlderVersion, and skipVersionCheck, including the prerelease and fail-open cases and each skip path.

One design note worth flagging: the check runs before flag parsing, so -endpoint and -config passed as flags aren't picked up by the early config read. The endpoint resolves from SRC_ENDPOINT, the config file, or the default. I kept it there to preserve the fail-open behavior, but happy to move the call after config resolution if you'd rather flags be honored.

I'll close #1339 and #1343 as superseded. PTAL when you have a chance.

Cheers,
Michael

Before running a command, src does a best-effort check of the running version against the version recommended by the configured instance (/.api/src-cli/version) and prints a single stderr warning when behind. Fail-open, 3s timeout, stderr only so --json is unaffected. Skips version/help/no-arg, dev builds, and SRC_SKIP_VERSION_CHECK. Compares major/minor/patch only. Adds unit tests. Closes sourcegraph#930. Supersedes sourcegraph#1339, sourcegraph#1343.
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.

1 participant