fix(discord): clamp limit to [1, 100] in _search_members and _fetch_messages - #19749
Open
sprmn24 wants to merge 1 commit into
Open
fix(discord): clamp limit to [1, 100] in _search_members and _fetch_messages#19749sprmn24 wants to merge 1 commit into
sprmn24 wants to merge 1 commit into
Conversation
sprmn24
force-pushed
the
fix/discord-limit-clamp
branch
from
May 25, 2026 15:09
815ef0c to
01965bd
Compare
teknium1
reviewed
Jul 12, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the focused fix. The premise is confirmed on current main: tools/discord_tool.py:495 and tools/discord_tool.py:521 still pass zero or negative limits through after applying only the upper cap. The proposed clamp correctly addresses both sites.
Problems
- Regression coverage is missing for the new lower bound.
tests/tools/test_discord_tool.py:390-395covers only the upper cap for member search, andtests/tools/test_discord_tool.py:423-429covers normal message pagination.
Suggested changes
- Add tests through the public Discord handlers for
limit=0and a negative limit on both actions, asserting the outbound request receives"limit": "1".
This is an automated hermes-sweeper review.
| @@ -332,7 +332,7 @@ def _search_members(token: str, guild_id: str, query: str, limit: int = 20, **_k | |||
| limit = int(limit) | |||
Contributor
There was a problem hiding this comment.
Please add regression coverage for this lower-bound branch. Current tests cover only the upper cap for search_members (tests/tools/test_discord_tool.py:390-395) and do not exercise zero or negative values for either action.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Clamps the
limitparameter to a valid range[1, 100]in two Discord tool functions. Previously only an upper bound of 100 was enforced viamin(limit, 100), allowing zero or negative values to be sent to the Discord API.Type of Change
Changes Made
_search_members:min(limit, 100)→max(1, min(limit, 100))_fetch_messages:min(limit, 100)→max(1, min(limit, 100))How to Test
Pass
limit=0orlimit=-5to either function — previously would send invalid value to Discord API, now clamps to 1.Checklist