Skip to content

Commit

Permalink
bug #1126 Fix detection of secondary rate limit (mathieudz)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.12-dev branch.

Discussion
----------

Actual error message is "You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID [...]"

Commits
-------

661fccb Fix detection of secondary rate limit
7d8aeb6 Update secondary rate limit test with new message
  • Loading branch information
mathieudz committed Nov 19, 2023
1 parent 67398b0 commit 9d19af3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Github/HttpClient/Plugin/GithubExceptionThrower.php
Expand Up @@ -128,7 +128,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
}

$reset = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Reset');
if ((403 === $response->getStatusCode()) && 0 < $reset && isset($content['message']) && (0 === strpos($content['message'], 'You have exceeded a secondary rate limit.'))) {
if ((403 === $response->getStatusCode()) && 0 < $reset && isset($content['message']) && (0 === strpos($content['message'], 'You have exceeded a secondary rate limit'))) {
$limit = (int) ResponseMediator::getHeader($response, 'X-RateLimit-Limit');

throw new ApiLimitExceedException($limit, $reset);
Expand Down
Expand Up @@ -103,7 +103,7 @@ public static function responseProvider()
],
json_encode(
[
'message' => 'You have exceeded a secondary rate limit. Please wait a few minutes before you try again.',
'message' => 'You have exceeded a secondary rate limit and have been temporarily blocked from content creation. Please retry your request again later. If you reach out to GitHub Support for help, please include the request ID #xxxxxxx.',
]
)
),
Expand Down

0 comments on commit 9d19af3

Please sign in to comment.