Wizard-generated SENTRY_AUTH_TOKEN blocks OAuth-based CLI login
Bug
## Summary
When a project contains a `.env.sentry-build-plugin` file with a `SENTRY_AUTH_TOKEN` generated by the Sentry wizard for sourcemap uploads, running `sentry-cli` in that directory silently uses that token instead of prompting for OAuth. The wizard-scoped token does not have the permissions required for general CLI operations, so commands fail with authentication errors while the user believes they are already logged in.
## Root cause
The CLI picks up `SENTRY_AUTH_TOKEN` from the environment (including dotenv files loaded by build tooling or the CLI itself). Tokens created by the wizard carry minimal scopes — sufficient for sourcemap upload but not for the broader scope set required by interactive CLI commands. There is no warning that the active token is insufficient for the requested operation; the user sees an auth error with no actionable guidance.
## Reproduction
1. Run the Sentry wizard in a project — it creates `.env.sentry-build-plugin` with a `SENTRY_AUTH_TOKEN`.
2. In the same project directory, run any `sentry-cli` command that requires OAuth-level scopes (e.g. `sentry-cli login`).
3. CLI reports it is authenticated via `SENTRY_AUTH_TOKEN` and skips OAuth, but the command fails due to insufficient scopes.
## Expected behavior
One of:
- The CLI detects that the ambient token lacks the required scopes for the requested operation and either falls back to OAuth or surfaces a clear, actionable error.
- The wizard-generated token is stored in a way that does not bleed into the interactive CLI environment (e.g. scoped to the build plugin only).
- The CLI warns the user: _"SENTRY_AUTH_TOKEN is set but does not have the required scopes for this operation. Unset it to use OAuth-based login."_
## Workaround
Unset `SENTRY_AUTH_TOKEN` before running interactive CLI commands:
```
SENTRY_AUTH_TOKEN= sentry-cli <command>
```
This loses sourcemap upload capability in that shell session but restores OAuth login flow.
Action taken on behalf of Burak Yigit Kaya.
关闭于 2026-04-02 2 条评论