GPT-5 finding
Missing input validation for non-positive trade sizes in buy_shares/sell_shares can raise unhandled ValueError and crash the loop
highapi-contracthigh
- backend/wonderwall/simulations/polymarket/amm.py:71-73
- backend/wonderwall/simulations/polymarket/platform.py:162-165
- backend/wonderwall/simulations/polymarket/amm.py:126-128
- backend/wonderwall/simulations/polymarket/platform.py:244-246
quote_buy and quote_sell explicitly raise on non-positive inputs. Platform buy_shares/sell_shares neither validate inputs nor catch these exceptions, and BasePlatform.running does not guard action handlers with try/except. A bad input (0 or negative) can propagate a ValueError and terminate the platform loop.
Recommendation
Add explicit validation in PolymarketPlatform.buy_shares and sell_shares: - If amount_usd <= 0 or num_shares <= 0, return {"success": False, "error": "amount_usd must be positive"} (or similar) without calling the AMM. - Alternatively, wrap the quote_* calls in try/except ValueError and convert to structured error responses.