Skip to content

fix(trace): allow 'trace view' to work with org-scoped targets#1291

Draft
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/trace-view-optional-project
Draft

fix(trace): allow 'trace view' to work with org-scoped targets#1291
sentry[bot] wants to merge 2 commits into
mainfrom
seer/fix/trace-view-optional-project

Conversation

@sentry

@sentry sentry Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Previously, running sentry trace view <org>/<trace-id> would fail with a ContextError: Specific project is required. This was due to the trace view command using resolveTraceOrgProject, which explicitly throws an error when an org-scoped target (without a project slug) is provided.

However, the underlying API call (getDetailedTrace) does not actually require a project slug to fetch trace details, making this restriction unnecessary for the trace view command.

This fix addresses the issue by:

  1. Introducing a new helper function, resolveTraceOrgOptionalProject, in src/lib/trace-target.ts. This function handles org-scoped targets by returning the organization and trace ID (with an undefined project), allowing the command to proceed. Other target types are delegated to the existing resolveTraceOrgProject to maintain strict project requirements for commands like span list and span view.
  2. Updating src/commands/trace/view.ts to use resolveTraceOrgOptionalProject. The command's subsequent logic already correctly handles an optional project, so no further changes were needed there.
  3. Updating the relevant unit test in test/commands/trace/view.func.test.ts to reflect the new, correct behavior for org-scoped targets.
  4. Addressing minor formatting and linting issues identified by CI.

Fixes CLI-VT

Comment @sentry <feedback> on this PR to have Autofix iterate on the changes.

@github-actions

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

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

Built to branch gh-pages at 2026-07-24 23:47 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@sentry sentry Bot changed the title fix(trace): make project optional for 'trace view' fix(trace): allow 'trace view' to work with org-scoped targets Jul 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ Patch coverage is 100.00%. Project has 5495 uncovered lines.
✅ Project coverage is 81.75%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.75%    81.75%        —%
==========================================
  Files          428       428         —
  Lines        30106     30110        +4
  Branches     19593     19595        +2
==========================================
+ Hits         24611     24615        +4
- Misses        5495      5495         —
- Partials      2054      2056        +2

Generated by Codecov Action

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.

0 participants