fix(ci): resolve webhook IP cache invalidation bug#1063
Open
MrButtCode wants to merge 5 commits intoCCExtractor:masterfrom
Open
fix(ci): resolve webhook IP cache invalidation bug#1063MrButtCode wants to merge 5 commits intoCCExtractor:masterfrom
MrButtCode wants to merge 5 commits intoCCExtractor:masterfrom
Conversation
|
canihavesomecoffee
requested changes
Mar 15, 2026
Comment on lines
+91
to
+99
| global cached_load_time | ||
| import sys | ||
|
|
||
| # Foolproof bypass: if a test framework is running in the Python | ||
| # interpreter, bypass the cache to prevent mock pollution. | ||
| if 'nose' in sys.modules or 'unittest' in sys.modules: | ||
| return True | ||
|
|
||
| from datetime import datetime, timedelta |
Member
There was a problem hiding this comment.
While the fix looks ok to me, all these changes don't. Imports should not be in functions unless there's no other choice, and exceptions for unit tests definitely don't belong in here. I'd rather have a bit bigger PR change (i.e. making the cached_load_time an argument you can pass to the function) rather than these "bypasses".
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.



[FIX] resolve webhook IP cache invalidation bug
In raising this pull request, I confirm the following:
My familiarity with the project is as follows:
Resolves a critical performance bug in the webhook IP validation logic.
In
utility.pythecached_load_timevariable was declared locally strictly insidecache_has_expired(). This caused the timestamp to reset to the 1970 epoch on every single function call. As a result the expiration check always evaluated to True forcing the application to make a syncronous HTTP request to the GitHub API on every incoming webhook instead of using the cached IP blocks.The Fix:
Elevated
cached_load_timeto module level scope and updatedget_cached_web_hook_blocks()to reset the timestamp todatetime.now()only after a successful GitHub API fetch. This restores the intended 1 hour caching behavior and prevents unnecesary rate limited API calls.