[FIX]: test_start_ci_empty_token fails under CI rate limiting#1092
Merged
canihavesomecoffee merged 1 commit intoCCExtractor:masterfrom Apr 7, 2026
Merged
Conversation
canihavesomecoffee
approved these changes
Apr 7, 2026
…nt rate-limit flakiness
fdc4ece to
5baca04
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



In raising this pull request, I confirm the following (please check boxes):
My familiarity with the project is as follows (check one):
Problem
Discovered while investigating the Python 3.13 build failure in PR #1091(failed run)
test_start_ci_empty_tokenwas failing intermittently with:The test is meant to verify that an empty GitHub token returns 500, but the request was being rejected by the
request_from_github()decorator with 418 before ever reaching the token check.Root cause:
BaseTestCase.setUp()correctly resets the webhook IP cache to empty before every test for isolation. This meansget_cached_web_hook_blocks()always makes a live call toapi.github.com/meta. Under CI rate limiting, multiple parallel matrix jobs can collectively exhaust GitHub's unauthenticated rate limit. GitHub then returns a 403 whose JSON body has nohookskey. TheKeyErrorhandler inget_cached_web_hook_blocks()catches this silently, leaving the cache empty.is_github_web_hook_ip()then returnsFalseandabort(418)fires — confirmed by this line in the failed log:Re-triggering after the rate limit reset passed, but this is nondeterministic and does not address the underlying issue.
Fix
Add
@mock.patch('requests.get', side_effect=mock_api_request_github)totest_start_ci_empty_token, exactly matching the pattern already used by every other/start-citest in the file (test_webhook_ping,test_webhook_release,test_webhook_push_github_api_failure).mock_api_request_githubalready exists intests/base.pyfor this purpose and returns valid GitHub hook IPs for the/metaURL.Verification
Confirmed locally on Python 3.13:
Notes
The test was introduced in commit
7c323efwith only@mock.patch('run.get_github_config')— therequests.getmock was missed. It passes locally because a single test run does not exhaust GitHub's unauthenticated rate limit, so the live call succeeds. CI exposes the missing mock because multiple parallel jobs can collectively exhaust the limit, causing the live call to fail.