feat(upgrade): add --offline flag and automatic offline fallback#450
feat(upgrade): add --offline flag and automatic offline fallback#450
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 91.27%. Project has 1118 uncovered lines. Files with missing lines (3)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 95.25% 95.23% -0.02%
==========================================
Files 174 174 —
Lines 23342 23433 +91
Branches 0 0 —
==========================================
+ Hits 22234 22315 +81
- Misses 1108 1118 +10
- Partials 0 0 —Generated by Codecov Action |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Autofix Details
Bugbot Autofix prepared fixes for both issues found in the latest run.
- ✅ Fixed: Auto-fallback incorrectly marks package manager upgrades as offline
- Auto-fallback now only sets offline=true for curl installs; package managers correctly set offline=false since they always hit the network.
- ✅ Fixed: Offline check result missing
offlinefield- Added offline parameter to buildCheckResult and updated both call sites to pass the offline value in check results.
Or push these changes by commenting:
@cursor push c8d1dcb547
Preview (c8d1dcb547)
diff --git a/src/commands/cli/upgrade.ts b/src/commands/cli/upgrade.ts
--- a/src/commands/cli/upgrade.ts
+++ b/src/commands/cli/upgrade.ts
@@ -167,7 +167,9 @@
}
return { kind: "target", target: resolved.target, offline: false };
} catch (error) {
- // Automatic offline fallback: if the network fails, try the cache
+ // Automatic offline fallback: if the network fails, try the cache.
+ // Only mark as offline for curl installs — package managers can't do
+ // offline upgrades and will still hit the network.
if (!(error instanceof UpgradeError && error.reason === "network_error")) {
throw error;
}
@@ -175,7 +177,8 @@
const target = resolveOfflineTarget(versionArg);
log.warn("Network unavailable, falling back to cached upgrade target");
log.info(`Using cached target: ${target}`);
- return { kind: "target", target, offline: true };
+ const isOffline = resolveOpts.method === "curl";
+ return { kind: "target", target, offline: isOffline };
} catch {
// No cached version either — re-throw original network error
throw error;
@@ -255,7 +258,14 @@
if (flags.check) {
return {
kind: "done",
- result: buildCheckResult({ target, versionArg, method, channel, flags }),
+ result: buildCheckResult({
+ target,
+ versionArg,
+ method,
+ channel,
+ flags,
+ offline: false,
+ }),
};
}
@@ -300,8 +310,9 @@
method: InstallationMethod;
channel: ReleaseChannel;
flags: UpgradeFlags;
+ offline?: boolean;
}): UpgradeResult {
- const { target, versionArg, method, channel, flags } = opts;
+ const { target, versionArg, method, channel, flags, offline } = opts;
const result: UpgradeResult = {
action: "checked",
currentVersion: CLI_VERSION,
@@ -309,6 +320,7 @@
channel,
method,
forced: flags.force,
+ offline: offline || undefined,
};
// When already on target, no update hint needed
@@ -620,7 +632,14 @@
// --check with offline just reports the cached version
if (flags.check) {
return yield new CommandOutput(
- buildCheckResult({ target, versionArg, method, channel, flags })
+ buildCheckResult({
+ target,
+ versionArg,
+ method,
+ channel,
+ flags,
+ offline,
+ })
);
}This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
bcba4ee to
8d6b6e9
Compare
1114da8 to
1f6a025
Compare
4a322ef to
e285ac3
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Add --offline flag to 'sentry cli upgrade' that uses only cached version info (from background checks) and cached patches (from background prefetch) — no network calls at all. When a normal upgrade encounters a network error during version discovery, automatically falls back to the offline path if cached data is available, logging a warning about the fallback. The infrastructure for offline upgrades already existed: - Background version checks store latest version in SQLite - Background patch prefetch caches patch chains to disk - Delta upgrade already checks cache before network This change wires those pieces together with a new entry point. Changes: - Add --offline flag to upgrade command - Add resolveOfflineTarget() for cached version lookup - Add resolveTargetWithFallback() for auto network→cache fallback - Thread offline param through executeUpgrade/downloadBinaryToTemp to prevent full-binary download fallback when offline - Show '(offline, from cache)' in human output for offline upgrades - Validate --offline is only used with curl-installed binaries
a83119c to
37604f9
Compare


Add
--offlineflag tosentry cli upgradethat uses only cached version info(from background checks) and cached patches (from background prefetch) — no network
calls at all. When a normal upgrade encounters a network error, automatically falls
back to the offline path if cached data is available.
How it works
The infrastructure for offline upgrades already existed:
This change wires those pieces together:
--offline→ usesgetVersionCheckInfo().latestVersionfrom SQLite instead offetchLatestVersion(), then letstryDeltaUpgrade()use cached patches onlyresolveTargetVersion()with a catch forUpgradeError("network_error"), falling back to the cached version + patchesofflineis true and no cached patches exist, throws a clear error insteadof falling through to
downloadFullBinary()Flag interactions
--offline--offline --check--offline --method npm