@@ -787,8 +787,9 @@ describe("viewCommand.func", () => {
787787 let openInBrowserSpy : ReturnType < typeof spyOn > ;
788788 let resolveProjectBySlugSpy : ReturnType < typeof spyOn > ;
789789
790+ const VALID_EVENT_ID = "abc123def456abc123def456abc123de" ;
790791 const sampleEvent : SentryEvent = {
791- eventID : "abc123def456" ,
792+ eventID : VALID_EVENT_ID ,
792793 title : "Error: test" ,
793794 metadata : { } ,
794795 contexts : { } ,
@@ -833,11 +834,11 @@ describe("viewCommand.func", () => {
833834
834835 const { context } = createMockContext ( ) ;
835836 const func = await viewCommand . loader ( ) ;
836- // "abc123def456" has no slash, "test-org/test-proj" has slash → swap detected
837+ // Valid 32-char hex has no slash, "test-org/test-proj" has slash → swap detected
837838 await func . call (
838839 context ,
839840 { json : true , web : false , spans : 0 } ,
840- "abc123def456" ,
841+ VALID_EVENT_ID ,
841842 "test-org/test-proj"
842843 ) ;
843844
@@ -904,13 +905,45 @@ describe("viewCommand.func", () => {
904905 context ,
905906 { json : true , web : false , spans : 0 } ,
906907 "test_org/test_proj" ,
907- "abc123def456"
908+ VALID_EVENT_ID
908909 ) ;
909910
910911 // parseOrgProjectArg normalizes "test_org/test_proj" → "test-org/test-proj"
911912 // and sets normalized=true, triggering the warning path (line 343-345)
912913 expect ( getEventSpy ) . toHaveBeenCalled ( ) ;
913914 } ) ;
915+
916+ test ( "throws ValidationError for flag-like event ID (--h)" , async ( ) => {
917+ const { context } = createMockContext ( ) ;
918+ const func = await viewCommand . loader ( ) ;
919+
920+ try {
921+ await func . call ( context , { json : false , web : false , spans : 0 } , "--h" ) ;
922+ expect . unreachable ( "Should have thrown" ) ;
923+ } catch ( error ) {
924+ expect ( error ) . toBeInstanceOf ( ValidationError ) ;
925+ const msg = ( error as ValidationError ) . message ;
926+ expect ( msg ) . toContain ( "event ID" ) ;
927+ expect ( msg ) . toContain ( "looks like a help flag" ) ;
928+ }
929+ } ) ;
930+
931+ test ( "throws ValidationError for non-hex event ID" , async ( ) => {
932+ const { context } = createMockContext ( ) ;
933+ const func = await viewCommand . loader ( ) ;
934+
935+ try {
936+ await func . call (
937+ context ,
938+ { json : false , web : false , spans : 0 } ,
939+ "not-a-hex-id"
940+ ) ;
941+ expect . unreachable ( "Should have thrown" ) ;
942+ } catch ( error ) {
943+ expect ( error ) . toBeInstanceOf ( ValidationError ) ;
944+ expect ( ( error as ValidationError ) . message ) . toContain ( "event ID" ) ;
945+ }
946+ } ) ;
914947} ) ;
915948
916949describe ( "fetchEventWithContext" , ( ) => {
0 commit comments