Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

fix(span): correctly parse multi-segment trace targets in single-arg view - #1283

Merged
BYK merged 5 commits into
mainfrom
seer/fix/span-view-multi-segment-arg
Jul 24, 2026
Merged

BYK merged 5 commits into
mainfrom
seer/fix/span-view-multi-segment-arg

Conversation

@sentry

@sentry sentry Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

This PR addresses issue CLI-1BD, where the sentry span view command would fail with a ContextError: Span ID is required. when a multi-segment trace target (e.g., org/project/trace-id/span-id) was provided as a single argument.

The root cause was that the parsePositionalArgs function in src/commands/span/view.ts only had specific logic to auto-split single arguments containing exactly one slash (<trace-id>/<span-id>). If the argument contained multiple slashes (as is common when copying from sentry span list output), this auto-split logic was bypassed, leading to no span ID being extracted and thus the error.

Changes introduced:

  1. Refactored Parsing Logic: The single-argument auto-splitting logic within parsePositionalArgs was extracted into a new helper function, tryAutoSplitSpanArg, to improve readability and reduce cognitive complexity.
  2. Enhanced Multi-Segment Handling: The tryAutoSplitSpanArg function was updated to correctly identify and split single arguments that contain multiple slashes, treating the last segment as the span ID and the preceding part as the trace target (which is then processed by parseSlashSeparatedTraceTarget).
  3. Preserved Single-Slash Validation: The original behavior for single-slash arguments (<trace-id>/<span-id>) was maintained, ensuring the trace ID portion is validated against HEX_ID_RE.
  4. Linting and Formatting: Addressed several Biome linting and formatting issues that arose during the refactoring, including block statement usage, logical expression simplification, and line-wrapping for chained method calls.

Fixes CLI-1BD

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

@github-actions

github-actions Bot commented Jul 22, 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-1283/

Built to branch gh-pages at 2026-07-22 17:40 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/commands/span/view.ts Resolved
Comment thread src/commands/span/view.ts Resolved
@github-actions

github-actions Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Codecov Results 📊

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

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    81.69%    81.70%    +0.01%
==========================================
  Files          426       426         —
  Lines        29969     29979       +10
  Branches     19496     19500        +4
==========================================
+ Hits         24483     24493       +10
- Misses        5486      5486         —
- Partials      2045      2045         —

Generated by Codecov Action

@sentry
sentry Bot requested a review from joseph-sentry July 22, 2026 17:55
@BYK
BYK merged commit 0341d1e into main Jul 24, 2026
34 checks passed
@BYK
BYK deleted the seer/fix/span-view-multi-segment-arg branch July 24, 2026 22:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants