@@ -473,6 +473,64 @@ describe('createScanFromGithub rate-limit short-circuit', () => {
473473 expect ( mockWithGitHubRetry ) . toHaveBeenCalledTimes ( 1 )
474474 } )
475475
476+ it ( 'returns ok:false and stops on GitHub GraphQL rate limit' , async ( ) => {
477+ mockWithGitHubRetry . mockResolvedValueOnce ( {
478+ ok : false ,
479+ message : 'GitHub GraphQL rate limit exceeded' ,
480+ cause : 'GraphQL rate limit hit.' ,
481+ } )
482+
483+ const { createScanFromGithub } = await import (
484+ '../../../../src/commands/scan/create-scan-from-github.mts'
485+ )
486+
487+ const result = await createScanFromGithub ( {
488+ all : false ,
489+ githubApiUrl : '' ,
490+ githubToken : '' ,
491+ interactive : false ,
492+ orgGithub : 'org' ,
493+ orgSlug : 'org' ,
494+ outputKind : 'text' ,
495+ repos : 'repo-a,repo-b,repo-c' ,
496+ } )
497+
498+ expect ( result . ok ) . toBe ( false )
499+ if ( ! result . ok ) {
500+ expect ( result . message ) . toBe ( 'GitHub GraphQL rate limit exceeded' )
501+ }
502+ expect ( mockWithGitHubRetry ) . toHaveBeenCalledTimes ( 1 )
503+ } )
504+
505+ it ( 'returns ok:false and stops on GitHub abuse detection' , async ( ) => {
506+ mockWithGitHubRetry . mockResolvedValueOnce ( {
507+ ok : false ,
508+ message : 'GitHub abuse detection triggered' ,
509+ cause : 'Secondary rate limit hit.' ,
510+ } )
511+
512+ const { createScanFromGithub } = await import (
513+ '../../../../src/commands/scan/create-scan-from-github.mts'
514+ )
515+
516+ const result = await createScanFromGithub ( {
517+ all : false ,
518+ githubApiUrl : '' ,
519+ githubToken : '' ,
520+ interactive : false ,
521+ orgGithub : 'org' ,
522+ orgSlug : 'org' ,
523+ outputKind : 'text' ,
524+ repos : 'repo-a,repo-b,repo-c' ,
525+ } )
526+
527+ expect ( result . ok ) . toBe ( false )
528+ if ( ! result . ok ) {
529+ expect ( result . message ) . toBe ( 'GitHub abuse detection triggered' )
530+ }
531+ expect ( mockWithGitHubRetry ) . toHaveBeenCalledTimes ( 1 )
532+ } )
533+
476534 it ( 'returns ok:false and stops on GitHub auth failure' , async ( ) => {
477535 mockWithGitHubRetry . mockResolvedValueOnce ( {
478536 ok : false ,
0 commit comments