Skip to content

fix: add trace ID validation to trace view + UUID dash-stripping#375

Merged
BYK merged 1 commit intomainfrom
fix/trace-view-validation
Mar 9, 2026
Merged

fix: add trace ID validation to trace view + UUID dash-stripping#375
BYK merged 1 commit intomainfrom
fix/trace-view-validation

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Mar 9, 2026

Fix two related issues (CLI-7Z, CLI-4X) in sentry trace view:

  1. Missing trace ID validationparsePositionalArgs() never called
    validateTraceId(), so raw user input went directly to the API. Invalid
    formats produced confusing "No trace found" errors instead of clear
    validation messages. Now matches the pattern used by trace logs.

  2. UUID dash-stripping — users often copy trace IDs in UUID format
    (e.g., ed29abc8-71c4-475b-9675-4655ef1a02d0). validateHexId() now
    auto-strips dashes when the input matches the 8-4-4-4-12 UUID pattern
    and logs a warning to stderr, following the project's auto-correct
    convention.

Changes

  • src/lib/hex-id.ts: Add UUID_DASH_RE regex and dash-stripping in
    validateHexId()
  • src/commands/trace/view.ts: Add validateTraceId() at all 4 return
    paths in parsePositionalArgs() via validateAndWarn() helper
  • Tests: Updated hex-id (unit + property), trace-id (unit + property),
    trace view (unit, property, func) — 123 tests pass

Fixes CLI-7Z
Fixes CLI-4X

Fix two related issues (CLI-7Z, CLI-4X) in `sentry trace view`:

1. Add missing `validateTraceId()` call in `parsePositionalArgs()` —
   the raw, unvalidated trace ID was going directly to the API, causing
   confusing "No trace found" errors for malformed input. Now matches
   the pattern used by `trace logs` and `log view`.

2. Add UUID dash-stripping in `validateHexId()` — when input matches
   UUID format (8-4-4-4-12 hex with dashes), dashes are automatically
   stripped and a warning is printed to stderr. This handles the common
   case of users copy-pasting trace IDs in UUID format (e.g.,
   `ed29abc8-71c4-475b-9675-4655ef1a02d0`).

Changes:
- src/lib/hex-id.ts: Add UUID_DASH_RE regex and dash-stripping before
  validation in validateHexId()
- src/commands/trace/view.ts: Add validateTraceId() at all 4 return
  paths in parsePositionalArgs(), with validateAndWarn() helper for
  UUID auto-correction warnings
- Updated tests: hex-id (unit + property), trace-id (unit + property),
  trace view (unit, property, func)
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (init) Add init command for guided Sentry project setup by betegon in #283
  • Magic @ selectors (@latest, @most_frequent) for issue commands by BYK in #371
  • Input hardening against agent hallucinations by BYK in #370
  • Add response caching for read-only API calls by BYK in #330

Bug Fixes 🐛

  • (docs) Remove double borders and fix column alignment on landing page tables by betegon in #369
  • Add trace ID validation to trace view + UUID dash-stripping by BYK in #375

Internal Changes 🔧

  • (init) Remove dead determine-pm step label by betegon in #374

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

Codecov Results 📊

104 passed | Total: 104 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 87.23%. Project has 4058 uncovered lines.
✅ Project coverage is 82.03%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
view.ts 93.85% ⚠️ 12 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    82.02%    82.03%    +0.01%
==========================================
  Files          140       140         —
  Lines        22547     22588       +41
  Branches         0         0         —
==========================================
+ Hits         18493     18530       +37
- Misses        4054      4058        +4
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review March 9, 2026 22:08
@BYK BYK merged commit e4cd3be into main Mar 9, 2026
21 checks passed
@BYK BYK deleted the fix/trace-view-validation branch March 9, 2026 22:25
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.

1 participant