fix(logs): cap search pagination to limit#30
Conversation
Stop fetching additional pages once the requested log limit is met to avoid unnecessary API calls and timeouts. - Track remaining results when paging - Trim response to the requested count
There was a problem hiding this comment.
Pull request overview
This pull request addresses issue #28 by implementing pagination limits for the logs search command to prevent long-running API calls and rate limit errors. Previously, the pagination loop would continue fetching all available pages regardless of the --limit flag value, resulting in excessive API calls and potential timeouts.
Changes:
- Modified the pagination loop condition to stop when the requested limit is reached
- Added logic to cap the page size for subsequent requests to the remaining needed logs
- Added post-loop trimming to ensure the final result respects the limit even if the API returns more logs than requested
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if remaining <= 0 { | ||
| break | ||
| } |
There was a problem hiding this comment.
This check for remaining <= 0 is redundant and unreachable. The loop condition at line 713 already ensures that len(allLogs) < logsLimit, which means remaining will always be greater than 0 when we reach this point. This code block can be removed.
| if remaining <= 0 { | |
| break | |
| } |
Summary
Stop log search pagination once the requested limit is reached to avoid long-running API calls and timeouts.
Changes
Testing
Related Issues
Closes #28