Skip to content

Show upgrade hint when a command fails and newer version exists #956

@sentry-junior

Description

@sentry-junior

When a command fails with an unexpected error (not a user/context error), and a newer CLI version is available, the CLI should show a contextual upgrade nudge. This helps users who may be hitting bugs already fixed in a later release.

Current behavior

  • The update notification in src/lib/version-check.ts (getUpdateNotification()) only fires after successful command completion
  • In src/cli.ts, the catch block writes the error and returns before reaching the notification code
  • Users who hit errors — the ones most likely to benefit from upgrading — never see the "new version available" message

Gap

Users hitting errors that are already fixed in a newer release have no way of knowing an upgrade might resolve their issue. The version check infrastructure (background fetch, SQLite cache, semver comparison) is already in place but not wired into the error path.

Suggested approach

  • Move or duplicate the update notification check into the error path in src/cli.ts so it also fires when a command throws

  • When triggered after an error (and a newer version is available), show a more contextual message, e.g.:

    A new version of sentry-cli is available (x.y.z). We fix a lot of bugs in every release, so upgrading may resolve this. If not, we guarantee we're already on it — after all, we're Sentry. Run sentry cli upgrade to update.

  • For ContextError (user misconfiguration), either skip the nudge or keep the standard "update available" copy — the contextual "upgrading may fix this" framing should target unexpected/internal errors only

Raised by Miguel Betegon.

Action taken on behalf of Aditya Mathur.

Metadata

Metadata

Labels

No labels
No labels
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions