From 53a5be77438b3483a65d027aa0d2afbe894dfde4 Mon Sep 17 00:00:00 2001 From: Derb237 <198724448+Derb237@users.noreply.github.com> Date: Fri, 24 Oct 2025 08:14:28 +0000 Subject: [PATCH] Fix spurious debug logging in api.py Fixed two bugs in the request error handling: 1. Line 153: Fixed typo where 'fail_reason' was set instead of 'reason_failed' for HTTP 412 status codes 2. Line 168: Moved unconditional debug log into a conditional that only logs terminal failures (400, 401, 403, 412) Previously, when debug mode was enabled, every HTTP request would log 'MISSION ALREADY CLAIMED' regardless of the actual status code or context. This was caused by an unconditional debug.log() call that always executed. Now, 'Mission already claimed' only appears for actual HTTP 412 errors. Bug introduced in commit c406ca9d (March 2, 2025) --- src/synack/plugins/api.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/synack/plugins/api.py b/src/synack/plugins/api.py index 1cc70c1..84d6e4f 100644 --- a/src/synack/plugins/api.py +++ b/src/synack/plugins/api.py @@ -150,7 +150,7 @@ def request(self, method, path, attempts=0, **kwargs): elif res.status_code == 403: reason_failed = 'Logged out' elif res.status_code == 412: - fail_reason = 'Mission already claimed' + reason_failed = 'Mission already claimed' elif res.status_code == 429: self._debug.log('Too many requests', f'({res.status_code} - {res.reason}) {res.url}') if attempts < 5: @@ -165,6 +165,8 @@ def request(self, method, path, attempts=0, **kwargs): attempts += 1 return self.request(method, path, attempts, **kwargs) - self._debug.log('Mission already claimed', f'({res.status_code} - {res.reason}) {res.url}') + # Log terminal failures (non-retryable errors) + if res.status_code in [400, 401, 403, 412]: + self._debug.log(reason_failed, f'({res.status_code} - {res.reason}) {res.url}') return res