From ff80b88fcf36c1a5f699b860cab86f2eb0f7c4c6 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 19 Feb 2026 15:05:27 +0000 Subject: [PATCH] Fix validation logic and syntax error in main.py Co-authored-by: abhimehro <84992105+abhimehro@users.noreply.github.com> --- main.py | 5 +---- tests/test_push_rules_perf.py | 1 - tests/test_rate_limit.py | 4 ++-- tests/test_retry_jitter.py | 1 + 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index a9ce7d7c..da9c0d2c 100644 --- a/main.py +++ b/main.py @@ -929,16 +929,13 @@ def validate_hostname(hostname: str) -> bool: f"Skipping unsafe hostname {sanitize_for_log(hostname)} (resolves to non-global/multicast IP {ip})" ) return False + return True except (socket.gaierror, ValueError, OSError) as e: log.warning( f"Failed to resolve/validate domain {sanitize_for_log(hostname)}: {sanitize_for_log(e)}" ) return False - if not addr_info: - return False - for res in addr_info: - @lru_cache(maxsize=128) def validate_folder_url(url: str) -> bool: diff --git a/tests/test_push_rules_perf.py b/tests/test_push_rules_perf.py index afd0bafb..9d42d682 100644 --- a/tests/test_push_rules_perf.py +++ b/tests/test_push_rules_perf.py @@ -25,7 +25,6 @@ def setUp(self): self.do = 1 self.status = 1 self.existing_rules = set() - self.main = main @patch("main.concurrent.futures.ThreadPoolExecutor") def test_push_rules_single_batch_optimization(self, mock_executor): diff --git a/tests/test_rate_limit.py b/tests/test_rate_limit.py index a7b17299..d047e633 100644 --- a/tests/test_rate_limit.py +++ b/tests/test_rate_limit.py @@ -260,10 +260,10 @@ def test_429_without_retry_after_uses_exponential_backoff(self): request_func = MagicMock(side_effect=[error, error, success_response]) # With delay=1, backoff should be: 1s, 2s - # Total wait should be >= 3 seconds + # With jitter (0.5x - 1.5x), total wait is >= 1.5s start_time = time.time() result = main._retry_request(request_func, max_retries=3, delay=1) elapsed = time.time() - start_time - assert elapsed >= 3.0 + assert elapsed >= 1.5 assert result == success_response diff --git a/tests/test_retry_jitter.py b/tests/test_retry_jitter.py index e1e0435c..414f901b 100644 --- a/tests/test_retry_jitter.py +++ b/tests/test_retry_jitter.py @@ -124,6 +124,7 @@ def test_four_hundred_errors_still_fail_fast(self): def test_429_rate_limit_retries_with_jitter(self): """Verify 429 rate limit errors retry with jittered backoff.""" response = Mock(status_code=429) + response.headers = {} error = httpx.HTTPStatusError( "Too many requests", request=Mock(),