Fix WiFi quick scan via agent and improve error messages

Agent fixes:
- Accept 'success' status for quick scans (not just 'started')
- WiFi quick scans return 'success' with results, not 'started'

Controller fixes:
- Pass through actual error messages from agent responses
- Previously showed generic "Agent returned error: 400"
- Now shows actual message like "Root privileges required for deep scan"
This commit is contained in:
cemaxecuter
2026-01-27 10:42:29 -05:00
parent 717dec4e54
commit c7e9a0a493
2 changed files with 24 additions and 9 deletions
+2 -1
View File
@@ -3596,7 +3596,8 @@ class InterceptAgentHandler(BaseHTTPRequestHandler):
if action == 'start':
result = mode_manager.start_mode(mode, body)
status = 200 if result.get('status') == 'started' else 400
# Accept both 'started' and 'success' as valid (quick scans return 'success')
status = 200 if result.get('status') in ('started', 'success') else 400
self._send_json(result, status)
elif action == 'stop':
result = mode_manager.stop_mode(mode)
+22 -8
View File
@@ -83,10 +83,17 @@ class AgentClient:
except requests.Timeout:
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
except requests.HTTPError as e:
raise AgentHTTPError(
f"Agent returned error: {e.response.status_code}",
status_code=e.response.status_code
)
# Try to extract error message from response body
error_msg = f"Agent returned error: {e.response.status_code}"
try:
error_data = e.response.json()
if 'message' in error_data:
error_msg = error_data['message']
elif 'error' in error_data:
error_msg = error_data['error']
except Exception:
pass
raise AgentHTTPError(error_msg, status_code=e.response.status_code)
except requests.RequestException as e:
raise AgentHTTPError(f"Request failed: {e}")
@@ -120,10 +127,17 @@ class AgentClient:
except requests.Timeout:
raise AgentConnectionError(f"Request to agent timed out after {self.timeout}s")
except requests.HTTPError as e:
raise AgentHTTPError(
f"Agent returned error: {e.response.status_code}",
status_code=e.response.status_code
)
# Try to extract error message from response body
error_msg = f"Agent returned error: {e.response.status_code}"
try:
error_data = e.response.json()
if 'message' in error_data:
error_msg = error_data['message']
elif 'error' in error_data:
error_msg = error_data['error']
except Exception:
pass
raise AgentHTTPError(error_msg, status_code=e.response.status_code)
except requests.RequestException as e:
raise AgentHTTPError(f"Request failed: {e}")