@@ -252,7 +252,7 @@ func (opts *IssuesOptions) Run(ctx context.Context, cmd *cobra.Command) error {
252252 opts .client = client
253253 opts .remote = remote
254254
255- issuesList , err := opts .resolveIssues (ctx , client , remote )
255+ issuesList , err := opts .resolveIssuesWithRetry (ctx , client , remote )
256256 if err != nil {
257257 return err
258258 }
@@ -283,6 +283,45 @@ func (opts *IssuesOptions) Run(ctx context.Context, cmd *cobra.Command) error {
283283 return nil
284284}
285285
286+ // resolveIssuesWithRetry calls resolveIssues and, for monorepos with an
287+ // auto-detected sub-repo path, progressively strips path segments on
288+ // "Repository does not exist" errors until a match is found.
289+ func (opts * IssuesOptions ) resolveIssuesWithRetry (ctx context.Context , client * deepsource.Client , remote * vcs.RemoteData ) ([]issues.Issue , error ) {
290+ issuesList , err := opts .resolveIssues (ctx , client , remote )
291+ if err == nil {
292+ return issuesList , nil
293+ }
294+
295+ if strings .Contains (err .Error (), "This repository is a monorepo" ) {
296+ return nil , fmt .Errorf ("This is a monorepo. Use --repo to specify a sub-project.\n \n Hint: %s" , err .Error ())
297+ }
298+
299+ if ! strings .Contains (err .Error (), "Repository does not exist" ) || remote .SubRepoSuffix == "" {
300+ return nil , err
301+ }
302+
303+ baseName := strings .SplitN (remote .RepoName , ":" , 2 )[0 ]
304+ parts := strings .Split (remote .SubRepoSuffix , ":" )
305+ for len (parts ) > 0 {
306+ parts = parts [:len (parts )- 1 ]
307+ remote .SubRepoSuffix = strings .Join (parts , ":" )
308+ if remote .SubRepoSuffix == "" {
309+ remote .RepoName = baseName
310+ } else {
311+ remote .RepoName = baseName + ":" + remote .SubRepoSuffix
312+ }
313+
314+ issuesList , err = opts .resolveIssues (ctx , client , remote )
315+ if err == nil {
316+ return issuesList , nil
317+ }
318+ if ! strings .Contains (err .Error (), "Repository does not exist" ) {
319+ return nil , err
320+ }
321+ }
322+ return nil , err
323+ }
324+
286325func (opts * IssuesOptions ) resolveIssues (ctx context.Context , client * deepsource.Client , remote * vcs.RemoteData ) ([]issues.Issue , error ) {
287326 serverFilters := opts .buildServerFilters ()
288327 prFilters := opts .buildPRFilters ()
@@ -314,7 +353,11 @@ func (opts *IssuesOptions) resolveIssues(ctx context.Context, client *deepsource
314353 case ab .PRNumber > 0 :
315354 opts .PRNumber = ab .PRNumber
316355 opts .CommitOid = ab .CommitOid
317- issuesList , err = client .GetPRIssues (ctx , remote .Owner , remote .RepoName , remote .VCSProvider , ab .PRNumber , prFilters )
356+ if ab .Fallback {
357+ issuesList , err = client .GetRunIssuesFlat (ctx , ab .CommitOid , serverFilters )
358+ } else {
359+ issuesList , err = client .GetPRIssues (ctx , remote .Owner , remote .RepoName , remote .VCSProvider , ab .PRNumber , prFilters )
360+ }
318361 case ab .UseRepo :
319362 issuesList , err = client .GetIssues (ctx , remote .Owner , remote .RepoName , remote .VCSProvider )
320363 default :
@@ -624,16 +667,20 @@ func (opts *IssuesOptions) renderHumanIssues() error {
624667 severity := humanizeSeverity (g .Key .IssueSeverity )
625668 sevTag := style .IssueSeverityColor (g .Key .IssueSeverity , "[" + severity + "]" )
626669
670+ // Build metadata suffix: "issue-code · Analyzer Name"
671+ meta := g .Key .IssueCode
672+ if analyzerName := g .Issues [0 ].Analyzer .Name ; analyzerName != "" {
673+ meta += " · " + analyzerName
674+ }
675+
627676 if len (g .Issues ) == 1 {
628- // Single occurrence: render exactly as before
629- fmt .Fprintf (w , " %s %s\n " , sevTag , g .Key .IssueText )
677+ fmt .Fprintf (w , " %s %s %s\n " , sevTag , g .Key .IssueText , pterm .Gray ("(" + meta + ")" ))
630678 if opts .Verbose && g .Description != "" {
631679 fmt .Fprintf (w , " %s\n " , pterm .Gray (g .Description ))
632680 }
633681 fmt .Fprintf (w , " %s\n " , pterm .Gray (formatLocation (g .Issues [0 ], cwd )))
634682 } else {
635- // Multi-occurrence: show count + compact locations
636- fmt .Fprintf (w , " %s %s (%d occurrences)\n " , sevTag , g .Key .IssueText , len (g .Issues ))
683+ fmt .Fprintf (w , " %s %s %s (%d occurrences)\n " , sevTag , g .Key .IssueText , pterm .Gray ("(" + meta + ")" ), len (g .Issues ))
637684 if opts .Verbose && g .Description != "" {
638685 fmt .Fprintf (w , " %s\n " , pterm .Gray (g .Description ))
639686 }
0 commit comments