Skip to content

Conversation

@combinatorist
Copy link
Contributor

@combinatorist combinatorist commented Sep 17, 2025

Now "max" means max.

This prevents overwhelming downstream systems, especially if the developer loads these into a database without realizing. #askingForAFriend ;)

while True:
params.update({'continue': cont_count})
max_page_results = min(50, max_results - cont_count)
params.update({'continue': cont_count, 'limit': max_page_results})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

More than open to style and logic suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, it seems we could move the cont_count < max_results criteria into the While condition above (and save 3 lines at the bottom of the function).

Added explicit type annotation to the 'params' dictionary in the search_entities function for improved code clarity and type checking.
@LeMyst LeMyst requested a review from Copilot September 19, 2025 09:50
Copy link
Contributor

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 PR enforces strict adherence to the maximum results limit in the search_entities function by calculating page-specific limits instead of using a fixed 50-result page size. This prevents accidentally retrieving more results than requested and protects downstream systems from being overwhelmed with data.

  • Modified the pagination logic to respect the exact max_results parameter
  • Added dynamic calculation of page size based on remaining results needed
  • Enhanced type annotations for the params dictionary

Comment on lines +457 to +458
max_page_results = min(50, max_results - cont_count)
params.update({'continue': cont_count, 'limit': max_page_results})
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The calculation max_results - cont_count can result in negative or zero values when cont_count >= max_results, which would cause max_page_results to be 0 or negative. This could lead to API errors or infinite loops. Add a check to break the loop when cont_count >= max_results before calculating max_page_results.

Copilot uses AI. Check for mistakes.
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.

2 participants