Skip to content

fix(upgrade): signal scope refresh via env var, not a version-skewed flag - #1453

Closed
betegon wants to merge 1 commit into
mainfrom
fix/upgrade-flag-skew
Closed

fix(upgrade): signal scope refresh via env var, not a version-skewed flag#1453
betegon wants to merge 1 commit into
mainfrom
fix/upgrade-flag-skew

Conversation

@betegon

@betegon betegon commented Aug 21, 2026

Copy link
Copy Markdown
Member

Summary

cli upgrade spawns the target binary's cli setup and appended --ensure-auth-scopes to its args (added in #1373, first shipped in 0.43.0). When the target binary predates that flag, its strict argument parser aborts on the unknown flag and the whole upgrade fails:

No flag registered for --ensure-auth-scopes
Error: Setup failed with exit code 252

Blast radius (with 0.43.0 now on stable)

  • Forward upgrades are safe. Any binary ≤0.42.2 runs an upgrade that never passes the flag, so 0.42.x → 0.43.0 works. This is the mass path.
  • Downgrades / rollbacks break. A user on 0.43.0 running sentry cli upgrade 0.42.x (rollback, pinned old version, CI clamped to an old release) passes the flag to a ≤0.42.2 setup, which rejects it → exit 252. The binary is not corrupted (parse fails before placement), but the upgrade aborts.

Reproduced:

$ sentry cli upgrade 0.42.2
No flag registered for --ensure-auth-scopes
Error: Setup failed with exit code 252

Fix

Route the intent through the SENTRY_ENSURE_AUTH_SCOPES env var instead of a CLI flag (same channel already used for SENTRY_INSTALL_DIR). An unknown env var is silently ignored by older binaries; an unknown flag is fatal. This makes the upgrade path robust across arbitrary version skew in both directions — not just this one flag. A comment documents that any future setup signal not guaranteed to exist in every upgradeable-from/-to version must travel the same way.

cli setup honors the env var and still accepts the legacy --ensure-auth-scopes flag (hidden), so already-deployed pre-fix binaries that pass the flag don't fail their parse when upgrading to a fixed binary.

Test plan

  • pnpm exec tsc --noEmit — clean
  • pnpm exec vitest run test/commands/cli/upgrade.test.ts test/commands/cli/setup.test.ts — 66/66 pass (assertions now check the env var; added coverage for the env-var trigger and the legacy-flag path)
  • pnpm exec biome check on changed files — clean

🤖 Generated with Claude Code

…flag

`cli upgrade` spawns the *target* binary's `cli setup` and appended
`--ensure-auth-scopes` to its args. That flag is brand new (#1373, merged
to main but unreleased), so any target that predates it — a downgrade, or
a nightly upgrading to the current stable (0.42.2) — hits a strict
argument parser that aborts on the unknown flag, failing the whole upgrade
with "No flag registered for --ensure-auth-scopes" / exit 252. This already
breaks every nightly user trying to move to stable, and will break any
downgrade once 0.43.0 ships.

Route the intent through the `SENTRY_ENSURE_AUTH_SCOPES` env var instead
(same channel already used for `SENTRY_INSTALL_DIR`). An unknown env var is
silently ignored by older binaries, whereas an unknown flag is fatal, so
the upgrade path is now robust across arbitrary version skew in both
directions.

`cli setup` honors the env var and still accepts the legacy
`--ensure-auth-scopes` flag, so already-deployed pre-fix binaries that pass
the flag don't fail their parse when upgrading to a fixed binary.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli Ready Ready Preview Aug 21, 2026 8:36pm

Request Review

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