fix(init): match formatError priority order for WizardError message#981
Merged
Conversation
result.error (Mastra framework failure) takes precedence over result.result?.message (structured bail message), consistent with what formatError already shows in the terminal. In practice the two fields are mutually exclusive, so no behavior changes. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
Contributor
Codecov Results 📊✅ 6994 passed | Total: 6994 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 14211 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
- Coverage 77.06% 77.03% -0.03%
==========================================
Files 320 320 —
Lines 61852 61876 +24
Branches 0 0 —
==========================================
+ Hits 47664 47665 +1
- Misses 14188 14211 +23
- Partials 0 0 —Generated by Codecov Action |
BYK
added a commit
that referenced
this pull request
May 23, 2026
…1015) ## Summary Enhance `sentry local` for the agent monitoring launch with OTel semantic attribute rendering, JSON output, SSE reconnection, and several quality improvements. ### OTel Semantic Display Port `trace-semantic-display` from sentry-mcp ([PR #981](getsentry/sentry-mcp#981)) to enrich tail output with OTel semantic attribute rendering. Transactions with GenAI, MCP, HTTP, database, and other OTel attributes now show rich labels: ``` [gen_ai] chat anthropic/claude-4-sonnet [1200ms] [5 spans] [mcp] tools/call search_files [320ms] [db] SELECT users [postgresql] [12ms] ``` Covers 15 attribute families: GenAI, MCP, HTTP, database, GraphQL, RPC/cloud, messaging, FaaS, object stores, CloudEvents, CICD, feature flags, process, exception, and error types. Falls back to existing behavior when no semantic attributes are present. ### `--format json` (NDJSON) New `--format json` / `-F json` flag for machine-readable output. Each envelope item produces one JSON line with structured fields including semantic labels, stack frames, and source detection: ```json {"type":"transaction","op":"gen_ai","label":"chat anthropic/claude-4-sonnet","duration_ms":1200,"source":"server"} {"type":"error","error_type":"TypeError","message":"x is not a function","filename":"app.ts","lineno":42,"source":"server"} ``` ### `--filter ai` New filter value that matches transactions with GenAI or MCP OTel attributes, so you can focus on agent activity: `sentry local -f ai` ### SSE Reconnection The SSE consumer now reconnects automatically with exponential backoff on connection loss, using `Last-Event-ID` to resume from where the stream left off. Retry counter resets after successful reconnection. Transient HTTP errors after a previous successful session are retried rather than treated as fatal. ### Quality Improvements - **Signal handler leak fixed** in `run.ts` — named handler refs, cleanup in `finally`, settled flag for close/error race - **`parsePort` deduplicated** — single implementation exported from `server.ts` - **`SENTRY_TRACES_SAMPLE_RATE`** preserved when already set (uses `??` fallback) - **Startup banner** with ingest URL, SSE endpoint, and connection hints - **Agent monitoring docs** with GenAI/MCP examples and JSON output section ## Files Changed | File | Change | |------|--------| | `src/lib/formatters/semantic-display.ts` | **New** — OTel semantic attribute rendering (15 families) | | `src/lib/formatters/local.ts` | Semantic display integration, JSON formatters, `--filter ai`, `inferSourceName` | | `src/commands/local/server.ts` | SSE reconnection, `--format json`, `--filter ai`, `parsePort` export, `feedSSELine` id tracking, startup banner | | `src/commands/local/run.ts` | Signal handler fix, `parsePort` import, env var preservation | | `docs/src/fragments/commands/local.md` | Agent monitoring section, JSON output section | | `test/lib/formatters/semantic-display.test.ts` | **New** — 70+ tests for all semantic formatters | | `test/lib/formatters/local.test.ts` | AI transaction tests, JSON format tests | | `test/commands/local/server.test.ts` | **New** — parsePort, feedSSELine, buildApp, CORS, isServerRunning | | `test/commands/local/run.test.ts` | Expanded — ENOENT, env preservation, separator handling | --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.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
The squash merge for #980 captured the first 3 commits but missed the priority-order fix that came in as a follow-up from a bot review. Main currently has
result.result?.message ?? result.errorbutformatError(which writes to the terminal) uses the opposite:result.error ?? inner?.message. This makes the terminal output and the Sentry exception message inconsistent when both fields are set.Changes
One-line fix in
handleFinalResult(wizard-runner.ts): swap the operands so the Sentry message usesresult.error ?? result.result?.message, matchingformatErrorexactly.In practice the two fields are mutually exclusive (structured bails populate
result.result.message; Mastra framework failures populateresult.error), so there's no user-visible behaviour change — just consistency between what the terminal shows and what Sentry captures.Test Plan
Existing tests in
wizard-runner-handle-final-result.mocked.test.tscover both theresult.errorandresult.result.messagepaths and pass unchanged.