Skip to content

fix(logs): cap search pagination to limit#30

Merged
platinummonkey merged 1 commit into
DataDog:mainfrom
manishprivet:fix/logs-search-limit
Feb 11, 2026
Merged

fix(logs): cap search pagination to limit#30
platinummonkey merged 1 commit into
DataDog:mainfrom
manishprivet:fix/logs-search-limit

Conversation

@manishprivet
Copy link
Copy Markdown
Contributor

@manishprivet manishprivet commented Feb 11, 2026

Summary

Stop log search pagination once the requested limit is reached to avoid long-running API calls and timeouts.

Changes

  • Cap pagination to the remaining limit and trim results (cmd/logs_simple.go:705)

Testing

  • go test ./...

Related Issues

Closes #28

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
Copilot AI review requested due to automatic review settings February 11, 2026 02:03
@manishprivet manishprivet requested a review from a team as a code owner February 11, 2026 02:03
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cmd/logs_simple.go
Comment on lines +728 to +730
if remaining <= 0 {
break
}
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if remaining <= 0 {
break
}

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@platinummonkey platinummonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!‏

@platinummonkey platinummonkey merged commit febf62d into DataDog:main Feb 11, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logs search: --limit flag ignored, fetches all pages

3 participants