Fix IGNORE_IP_REGEX_START never matching localhost IPs#280
Open
Chessing234 wants to merge 1 commit intoallenai:mainfrom
Open
Fix IGNORE_IP_REGEX_START never matching localhost IPs#280Chessing234 wants to merge 1 commit intoallenai:mainfrom
Chessing234 wants to merge 1 commit intoallenai:mainfrom
Conversation
IGNORE_IP_REGEX_START is compiled with r"^{IGNORE_IP_REGEX.pattern}",
which is a raw string that literally matches the text
"{IGNORE_IP_REGEX.pattern}" instead of expanding the regex pattern.
This means the localhost IP check on line 97 never matches, so
127.0.0.1, 0.0.0.0, and ::1 are incorrectly yielded as blocklist
URLs. The adjacent ONLY_URL_REGEX and ADP_FORMAT_REGEX both correctly
use f-strings for the same interpolation pattern.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
BaseUrlTagger.IGNORE_IP_REGEX_STARTuses anr"..."(raw string) instead off"..."(f-string), so the regex is compiled as the literal text^{IGNORE_IP_REGEX.pattern}rather than expanding to^(127\.0\.0\.1|0\.0\.0\.0|::1).Bug: Line 62 —
re.compile(r"^{IGNORE_IP_REGEX.pattern}")never matches any real IP.Impact: The localhost check at line 97 (
if not self.IGNORE_IP_REGEX_START.match(...)) always passes, so127.0.0.1,0.0.0.0, and::1are incorrectly yielded as blocklist URLs instead of being filtered out.Evidence: The adjacent
ONLY_URL_REGEX(line 64) andADP_FORMAT_REGEX(line 65) both correctly usef"..."for the same interpolation pattern.Fix: Change
r"..."→f"..."on line 62.Test plan
^{IGNORE_IP_REGEX.pattern}^(127\.0\.0\.1|0\.0\.0\.0|::1)