diff --git a/lib/util/http/github.spec.ts b/lib/util/http/github.spec.ts index 67fc7e5a2c60bf3c1ec45c5f04112a01582576e3..9f9340264c4614b45b529500553a8f5f27e6f3eb 100644 --- a/lib/util/http/github.spec.ts +++ b/lib/util/http/github.spec.ts @@ -192,6 +192,14 @@ describe('util/http/github', () => { }) ).rejects.toThrow(PLATFORM_RATE_LIMIT_EXCEEDED); }); + it('should throw secondary rate limit exceeded', async () => { + await expect( + fail(403, { + message: + 'You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later.', + }) + ).rejects.toThrow(PLATFORM_RATE_LIMIT_EXCEEDED); + }); it('should throw Bad credentials', async () => { await expect( fail(401, { message: 'Bad credentials. (401)' }) diff --git a/lib/util/http/github.ts b/lib/util/http/github.ts index c181dcb6f10f06fd71f79eedc3bbc24b7dc4129d..a96fad6973222cbde6f187af1997bfb6a1c702e8 100644 --- a/lib/util/http/github.ts +++ b/lib/util/http/github.ts @@ -78,6 +78,13 @@ function handleGotError( logger.debug({ err }, 'GitHub failure: abuse detection'); throw new Error(PLATFORM_RATE_LIMIT_EXCEEDED); } + if ( + err.statusCode === 403 && + message.startsWith('You have exceeded a secondary rate limit') + ) { + logger.debug({ err }, 'GitHub failure: secondary rate limit'); + throw new Error(PLATFORM_RATE_LIMIT_EXCEEDED); + } if (err.statusCode === 403 && message.includes('Upgrade to GitHub Pro')) { logger.debug({ path }, 'Endpoint needs paid GitHub plan'); throw err;