diff --git a/tradingagents/dataflows/polymarket.py b/tradingagents/dataflows/polymarket.py index 97637cf..147ba95 100644 --- a/tradingagents/dataflows/polymarket.py +++ b/tradingagents/dataflows/polymarket.py @@ -52,10 +52,18 @@ def _request(path: str, params: dict) -> dict: "-p", str(port), f"root@{host}", f'curl -s "{full_url}"' ] - result = subprocess.run(cmd, capture_output=True, text=True, timeout=REQUEST_TIMEOUT) + try: + result = subprocess.run(cmd, capture_output=True, text=True, timeout=REQUEST_TIMEOUT) + except subprocess.TimeoutExpired: + raise requests.RequestException("SSH proxy timed out") if result.returncode != 0: raise requests.RequestException(f"SSH proxy failed: {result.stderr}") - return json.loads(result.stdout) + if not result.stdout or not result.stdout.strip(): + raise requests.RequestException("SSH proxy returned empty response") + try: + return json.loads(result.stdout) + except json.JSONDecodeError as e: + raise requests.RequestException(f"SSH proxy returned invalid JSON: {e}") def _parse_json_list(value) -> list: