Skip to content

fix: three bug fixes — span list cross-project, init ANSI escapes, DSN env detection#852

Draft
cursor[bot] wants to merge 4 commits intomainfrom
cursor/sentry-cli-bug-fixes-4540
Draft

fix: three bug fixes — span list cross-project, init ANSI escapes, DSN env detection#852
cursor[bot] wants to merge 4 commits intomainfrom
cursor/sentry-cli-bug-fixes-4540

Conversation

@cursor
Copy link
Copy Markdown
Contributor

@cursor cursor Bot commented Apr 27, 2026

Summary

Three independent bug fixes for open issues:


1. fix(span-list): query all projects in trace mode for cross-project traces (#735)

Root cause: listSpans() always scoped API queries to a single project via project:{slug}. For traces spanning multiple projects, the auto-detected project might not participate in the trace, returning empty results.

Trigger: sentry span list <trace-id> where the trace spans 4+ projects.

Fix: Added allProjects option to listSpans() that sends project=-1 (all projects). Trace mode now uses this since the trace:{id} query already scopes results correctly. This matches how getDetailedTrace() works for trace view.


2. fix(init): suppress raw ANSI escape sequences when output is piped (#746)

Root cause: @clack/prompts (intro, log, cancel, etc.) writes raw ANSI control sequences unconditionally — cursor hide/show (\x1b[?25l), erase codes, spinner animation. The init wizard used these directly without checking isPlainOutput().

Trigger: sentry init --yes | tee log.txt or any piped/redirected output.

Fix: Created clack-plain.ts adapter that intercepts clack function calls. In non-TTY/plain mode, it replaces ANSI-heavy output with clean plain text. Also updated the wizard spinner to check isPlainOutput() before emitting cursor control sequences.


3. fix(dsn): detect framework-prefixed DSN env vars in .env files and process.env (#820)

Root cause: DSN detection only matched SENTRY_DSN=... in .env files and process.env.SENTRY_DSN at runtime. Framework-prefixed variants like NEXT_PUBLIC_SENTRY_DSN, REACT_APP_SENTRY_DSN, VITE_SENTRY_DSN were not detected, causing sentry init to create a new project instead of reusing.

Trigger: Having a DSN via NEXT_PUBLIC_SENTRY_DSN in .env.local and running sentry init.

Fix: Expanded the .env file regex to ^(?:\w+_)?SENTRY_DSN to match any prefix. Added explicit runtime checks for the 5 most common framework-prefixed env vars after the canonical SENTRY_DSN.

Open in Web View Automation 

cursoragent and others added 3 commits April 27, 2026 12:26
…aces (#735)

In trace mode, `sentry span list <trace-id>` was always scoping the
spans query to a single project via `project:{slug}` in the API query.
For traces spanning multiple projects, this returned empty results because
the auto-detected project may not match any of the projects in the trace.

The fix adds an `allProjects` option to `listSpans` that sends
`project=-1` (all projects) instead of a single-project filter. This
matches how `getDetailedTrace` (used by `trace view`) works for
cross-project traces. The trace mode handler now passes `allProjects: true`
since the `trace:{id}` query filter already scopes results correctly.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
)

When `sentry init --yes` output is piped or redirected, @clack/prompts
writes raw terminal control sequences (cursor hide/show, erase codes,
spinner animation) that make captured output unreadable.

The fix adds a thin adapter module (clack-plain.ts) that intercepts all
clack function calls used by the init wizard. When `isPlainOutput()` is
true (non-TTY, NO_COLOR, etc.), the adapter replaces clack's box-drawing
and ANSI-heavy output with clean, plain-text equivalents. Interactive
prompts (confirm, select, multiselect) pass through to real clack since
they're only reached in TTY mode.

Also updated the wizard spinner to check `isPlainOutput()` in addition
to `isTTY` before writing cursor hide/show sequences and starting the
animation timer.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
…ocess.env (#820)

`sentry init` was not detecting DSNs supplied via framework-specific
environment variables like `NEXT_PUBLIC_SENTRY_DSN`, `REACT_APP_SENTRY_DSN`,
`VITE_SENTRY_DSN`, etc. This caused init to create a new Sentry project
instead of reusing the existing one when the DSN was provided through a
framework-prefixed env var.

The .env file scanner (env-file.ts) only matched the exact pattern
`SENTRY_DSN=...`. The runtime env detection (env.ts) only checked
`process.env.SENTRY_DSN`.

Fix:
- Expanded the .env file regex from `^SENTRY_DSN` to `^(?:\w+_)?SENTRY_DSN`
  to match framework-prefixed variants (NEXT_PUBLIC_, REACT_APP_, VITE_, etc.)
- Added explicit checks for the 5 most common framework-prefixed env vars
  in the runtime env detection, checked after the canonical SENTRY_DSN

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 27, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-852/

Built to branch gh-pages at 2026-04-27 12:38 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

…mpts

The clack-plain adapter routes to plain-text handlers when isPlainOutput()
is true (non-TTY in test environment). Tests that spy on the real clack
namespace need rich mode to be active so the adapter delegates through
to the spied functions.

Co-authored-by: Miguel Betegón <miguelbetegongarcia@gmail.com>
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