-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix(span): correctly parse multi-segment trace targets in single-arg view #1267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,29 @@ export function parsePositionalArgs(args: string[]): SpanViewArgs { | |
| } | ||
| } | ||
|
|
||
| // Auto-detect `<org>/<project>/<trace-id>/<span-id>` single-arg form with | ||
| // multiple slashes. When the last segment is a valid 16-char hex span ID, | ||
| // split it off and defer the trace portion to parseTraceTargetWithRecovery. | ||
| if (args.length === 1 && first.indexOf("/") !== -1) { | ||
| const lastSlash = first.lastIndexOf("/"); | ||
| const maybeSpanId = first | ||
| .slice(lastSlash + 1) | ||
| .trim() | ||
| .toLowerCase() | ||
| .replace(/-/g, ""); | ||
| const traceArg = first.slice(0, lastSlash); | ||
| // Only treat it as a combined trace/span arg when the prefix still | ||
| // contains a slash (i.e. this is truly multi-segment like org/proj/trace/span). | ||
| // The single-slash `<trace-id>/<span-id>` case is already handled above. | ||
| if (traceArg.includes("/") && SPAN_ID_RE.test(maybeSpanId)) { | ||
| log.warn( | ||
| `Interpreting '${first}' as <trace-target>/<span-id>. ` + | ||
| `Use separate arguments: sentry span view ${traceArg} ${maybeSpanId}` | ||
| ); | ||
| return { kind: "deferred", rawTraceArg: traceArg, rawSpanIds: [maybeSpanId] }; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefix missing trace ID acceptedMedium Severity The new single-argument splitter treats any path whose prefix still contains Reviewed by Cursor Bugbot for commit 2dc800b. Configure here. |
||
| } | ||
|
|
||
| // Single bare arg that looks like a span ID (16-char hex, no slashes): | ||
| // the user forgot the trace ID. Give a targeted ContextError instead | ||
| // of the confusing "Invalid trace ID" from validateTraceId() (CLI-SC). | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: The warning for combined arguments like
org/project/traceId/spanIdshows a normalized span ID (dashes removed), which can be confusing as it differs from the user's original input.Severity: LOW
Suggested Fix
To avoid user confusion, the warning message should display the original, un-normalized span ID as entered by the user. The normalized version of the span ID should still be used internally for validation and further processing, but the user-facing output should reflect their exact input.
Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.