File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -247,7 +247,7 @@ const customText: ApplicationText = {
247247 return `${ text_en . exceptionWhileParsingArguments ( exc , ansiColor ) } ${ pluralHint } ` ;
248248 }
249249
250- // With defaultCommand: "view", unknown tokens like "events " fill the
250+ // With defaultCommand: "view", unknown tokens like "metrics " fill the
251251 // positional slot, then extra args (e.g., CLI-AB) trigger this error.
252252 // Check if the first non-route token is a known synonym.
253253 const synonymHint = getSynonymSuggestionFromArgv ( ) ;
@@ -308,7 +308,7 @@ const customText: ApplicationText = {
308308 throw exc ;
309309 }
310310
311- // Case C: With defaultCommand: "view", unknown tokens like "events " are
311+ // Case C: With defaultCommand: "view", unknown tokens like "metrics " are
312312 // silently consumed as the positional arg. The view command fails at the
313313 // domain level (e.g., ResolutionError). Check argv for a known synonym
314314 // and show the suggestion — skip Sentry capture since these are known
Original file line number Diff line number Diff line change @@ -222,6 +222,32 @@ describe("parsePositionalArgs", () => {
222222 ValidationError
223223 ) ;
224224 } ) ;
225+
226+ test ( "throws ContextError for bare span ID without trace ID (CLI-SC)" , ( ) => {
227+ expect ( ( ) => parsePositionalArgs ( [ "a1b2c3d4e5f67890" ] ) ) . toThrow (
228+ ContextError
229+ ) ;
230+ } ) ;
231+
232+ test ( "bare span ID error identifies the input and suggests correct usage" , ( ) => {
233+ try {
234+ parsePositionalArgs ( [ "A1B2C3D4E5F67890" ] ) ;
235+ expect . unreachable ( "Should have thrown" ) ;
236+ } catch ( error ) {
237+ expect ( error ) . toBeInstanceOf ( ContextError ) ;
238+ const msg = ( error as ContextError ) . message ;
239+ expect ( msg ) . toContain ( "looks like a span ID" ) ;
240+ expect ( msg ) . toContain ( "sentry span view <trace-id> a1b2c3d4e5f67890" ) ;
241+ expect ( msg ) . toContain ( "sentry trace list" ) ;
242+ }
243+ } ) ;
244+
245+ test ( "bare span ID with dashes is still detected (CLI-SC)" , ( ) => {
246+ // Some tools format span IDs with dashes
247+ expect ( ( ) => parsePositionalArgs ( [ "a1b2-c3d4-e5f6-7890" ] ) ) . toThrow (
248+ ContextError
249+ ) ;
250+ } ) ;
225251 } ) ;
226252} ) ;
227253
Original file line number Diff line number Diff line change @@ -68,6 +68,12 @@ describe("suggestPlatform", () => {
6868 expect ( results ) . toContain ( "javascript-react" ) ;
6969 } ) ;
7070
71+ test ( "suggests middle-component match: javascript-cloudflare → node-cloudflare-* (CLI-WD)" , ( ) => {
72+ const results = suggestPlatform ( "javascript-cloudflare" ) ;
73+ expect ( results ) . toContain ( "node-cloudflare-pages" ) ;
74+ expect ( results ) . toContain ( "node-cloudflare-workers" ) ;
75+ } ) ;
76+
7177 test ( "returns empty array for garbage input" , ( ) => {
7278 expect ( suggestPlatform ( "xyzgarbage" ) ) . toEqual ( [ ] ) ;
7379 } ) ;
You can’t perform that action at this time.
0 commit comments