From b288934dffcc3f38938931e2947e9e49c8602b34 Mon Sep 17 00:00:00 2001 From: sprmn24 Date: Mon, 27 Apr 2026 00:56:57 +0300 Subject: [PATCH] fix(discord_tool): coerce limit parameter to int before min() call _search_members() and _fetch_messages() call min(limit, 100) assuming limit is int. Models can pass limit as a string (e.g. "10"), causing TypeError: '<' not supported between instances of 'str' and 'int'. Add try/except int() coercion with safe defaults at the top of both functions, matching the pattern used in session_search fix (#10522). --- tools/discord_tool.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/discord_tool.py b/tools/discord_tool.py index dff0c67669..88e8c9fb28 100644 --- a/tools/discord_tool.py +++ b/tools/discord_tool.py @@ -328,6 +328,10 @@ def _member_info(token: str, guild_id: str, user_id: str, **_kwargs: Any) -> str def _search_members(token: str, guild_id: str, query: str, limit: int = 20, **_kwargs: Any) -> str: """Search for guild members by name.""" + try: + limit = int(limit) + except (TypeError, ValueError): + limit = 20 params = {"query": query, "limit": str(min(limit, 100))} members = _discord_request("GET", f"/guilds/{guild_id}/members/search", token, params=params) result = [] @@ -350,6 +354,10 @@ def _fetch_messages( **_kwargs: Any, ) -> str: """Fetch recent messages from a channel.""" + try: + limit = int(limit) + except (TypeError, ValueError): + limit = 50 params: Dict[str, str] = {"limit": str(min(limit, 100))} if before: params["before"] = before