fix: three bug fixes — span list cross-project, init ANSI escapes, DSN env detection#852
Draft
cursor[bot] wants to merge 4 commits intomainfrom
Draft
fix: three bug fixes — span list cross-project, init ANSI escapes, DSN env detection#852cursor[bot] wants to merge 4 commits intomainfrom
cursor[bot] wants to merge 4 commits intomainfrom
Conversation
…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>
Contributor
|
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 viaproject:{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
allProjectsoption tolistSpans()that sendsproject=-1(all projects). Trace mode now uses this since thetrace:{id}query already scopes results correctly. This matches howgetDetailedTrace()works fortrace 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 checkingisPlainOutput().Trigger:
sentry init --yes | tee log.txtor any piped/redirected output.Fix: Created
clack-plain.tsadapter 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 checkisPlainOutput()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 andprocess.env.SENTRY_DSNat runtime. Framework-prefixed variants likeNEXT_PUBLIC_SENTRY_DSN,REACT_APP_SENTRY_DSN,VITE_SENTRY_DSNwere not detected, causingsentry initto create a new project instead of reusing.Trigger: Having a DSN via
NEXT_PUBLIC_SENTRY_DSNin.env.localand runningsentry init.Fix: Expanded the .env file regex to
^(?:\w+_)?SENTRY_DSNto match any prefix. Added explicit runtime checks for the 5 most common framework-prefixed env vars after the canonicalSENTRY_DSN.