Skip to content

fix(local): Point trace view --web at the trace detail route - #1314

Merged
jared-outpost[bot] merged 4 commits into
mainfrom
fix/trace-web-url
Jul 30, 2026
Merged

fix(local): Point trace view --web at the trace detail route#1314
jared-outpost[bot] merged 4 commits into
mainfrom
fix/trace-web-url

Conversation

@sergical

@sergical sergical commented Jul 29, 2026

Copy link
Copy Markdown
Member

What was broken

Three commands printed or opened links that don't work:

  • sentry trace view --web <trace-id> — opens the traces list instead of the trace you asked for
  • sentry trace logs --web <trace-id> — same
  • sentry log view <log-id> — the Link row it prints is a dead link

In every case you end up on a list page with your trace ID silently dropped.

Why

We build the URL as:

https://my-org.sentry.io/traces/{traceId}/

That path doesn't exist. In Sentry's router the trace page lives at trace/:traceSlug/, mounted under both traces/ and explore/traces/. So the real URL needs a trace/ segment in the middle:

https://my-org.sentry.io/explore/traces/trace/{traceId}/

Without it the URL matches the list route instead, and the ID is thrown away. That's why you land on the list.

This is just old code. The other builders in the same file were already moved to the new explore/ paths (buildLogsUrl/explore/logs/, buildReplayUrl/explore/replays/{id}/). Traces got missed.

The fix

  1. Build the correct URL — add the missing trace/ segment and the explore/ prefix.
  2. Teach the URL parser about the new path, so pasting a trace URL into the CLI still works.
  3. Keep parsing the old traces/{id}/ shape too, so links people already copied keep working.

Tests updated for the new URL, plus cases covering the old one so the fallback stays working.

🤖 Generated with Claude Code

`buildTraceUrl` emitted `/traces/{traceId}/`, which matches no route. The
trace detail view is mounted at `trace/:traceSlug/` under both `traces/` and
`explore/traces/`, so the `trace/` segment is what distinguishes a detail URL
from the traces list. Without it Sentry falls back to the list and drops the
trace ID, so `sentry trace view --web <id>` never opened the trace.

Switch to the canonical `/explore/traces/trace/{traceId}/`, matching the
`explore/` namespace `buildLogsUrl` and `buildReplayUrl` already use.

`parseSentryUrl` gains `matchTracePath`, mirroring `matchReplayPath`: it
accepts the canonical path and still parses legacy `traces/{id}/` links so
previously-copied URLs keep resolving.

Affects `trace view --web`, `trace logs --web`, and the `Link` row in
`formatLogDetails`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Jul 29, 2026
@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-30 10:19 UTC

@github-actions

github-actions Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 96.15%. Project has 5485 uncovered lines.
✅ Project coverage is 81.77%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/sentry-url-parser.ts 95.83% ⚠️ 1 Missing and 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.76%    81.77%    +0.01%
==========================================
  Files          430       430         —
  Lines        30063     30083       +20
  Branches     19707     19719       +12
==========================================
+ Hits         24578     24598       +20
- Misses        5485      5485         —
- Partials      2043      2043         —

Generated by Codecov Action

@MathurAditya724 MathurAditya724 added the jared Trigger the Jared agent to work on stuff label Jul 30, 2026

@jared-outpost jared-outpost Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

traced through this — the fix is correct. `explore/traces/trace/{id}` matches the sibling builders (`explore/logs/`, `explore/replays/{id}/`) already in this file, and the missing `trace/` segment is exactly why the ID was getting dropped onto the list route.

`matchTracePath` handles all three shapes cleanly (canonical, traces/trace/{id}, and legacy traces/{id}), and its ordering ahead of matchReplayPath is safe since it returns absent for anything that isn't traces. Legacy parse cases are retained, so previously-copied links keep resolving. verified the affected tests pass locally (the 2 applySentryUrlContext failures are pre-existing on main and unrelated).

one non-blocking nit: the parser file's top-level JSDoc (the "Recognizes these path patterns" list around lines 291/300) still only mentions the legacy traces/{traceId}/ form — worth adding the new canonical explore/traces/trace/{traceId}/ there for completeness. not a blocker.

@BYK

BYK commented Jul 30, 2026

Copy link
Copy Markdown
Member

Jared,

one non-blocking nit: the parser file's top-level JSDoc (the "Recognizes these path patterns" list around lines 291/300) still only mentions the legacy traces/{traceId}/ form — worth adding the new canonical explore/traces/trace/{traceId}/ there for completeness. not a blocker.

Push a commit fixing this please.

Also, check the PR against .lore.md file for repo conventions. If all checks out and no Seer or BugBot review comments, merge it away. Don't forget to thank @sergical!

@jared-outpost

jared-outpost Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Done — pushed e799547 adding the canonical explore/traces/trace/{traceId}/ form (marked legacy vs canonical) to both path-pattern lists in the parser JSDoc.

Checked against .lore.md: the change follows the existing explore/ path convention already used by buildLogsUrl/buildReplayUrl, and doesn't touch the isSaaS()/isSaaSTrustOrigin split. All CI green, and both Cursor Bugbot and Seer passed with no review comments — merging.

Thanks @sergical for the fix!

@jared-outpost
jared-outpost Bot enabled auto-merge (squash) July 30, 2026 10:02

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e799547. Configure here.

Comment thread src/lib/sentry-url-parser.ts
@jared-outpost
jared-outpost Bot disabled auto-merge July 30, 2026 10:03
Bugbot: matchTracePath treated any segment after explore/traces/ as a
trace ID even without the trace/ segment, so explore/traces/{slug}/
yielded a bogus traceId. Only the legacy non-explore traces/{id}/ form
should match without trace/; require it under explore/.
@jared-outpost
jared-outpost Bot enabled auto-merge (squash) July 30, 2026 10:07
Comment thread src/lib/sentry-url-parser.ts
@jared-outpost
jared-outpost Bot disabled auto-merge July 30, 2026 10:09
Seer: matchSubdomainPath handled matchReplayPath's list status (org-only)
but not the equivalent trace list status, so a bare subdomain trace list
URL (explore/traces/) returned null. Mirror the replay handling.
@jared-outpost
jared-outpost Bot enabled auto-merge (squash) July 30, 2026 10:10
@jared-outpost
jared-outpost Bot merged commit c67b6f0 into main Jul 30, 2026
30 checks passed
@jared-outpost
jared-outpost Bot deleted the fix/trace-web-url branch July 30, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jared Trigger the Jared agent to work on stuff risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants