Skip to content

refactor: added max size incase of paginate:false#3

Open
ysai258 wants to merge 3 commits intomasterfrom
REF-19943
Open

refactor: added max size incase of paginate:false#3
ysai258 wants to merge 3 commits intomasterfrom
REF-19943

Conversation

@ysai258
Copy link
Member

@ysai258 ysai258 commented Jan 22, 2026

Summary

This pull request makes a small change to the find function in lib/core/find.js to improve how the maximum number of results is handled when pagination is disabled.

  • When paginate is set to false, the size parameter now defaults to filters.$limit if specified, or to 10000 otherwise, ensuring a sensible maximum result size.

Task

BUG: Duplicate Clients Are Created After Bulk Uploading Documents

Related PR(s)

Screenshots

@gemini-code-assist
Copy link

Summary of Changes

Hello @ysai258, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a crucial adjustment to the data retrieval mechanism, specifically targeting scenarios where pagination is explicitly turned off. The primary goal is to prevent an excessive number of records from being fetched, which was identified as a root cause for duplicate client entries during bulk document uploads. By implementing a default maximum size, the change ensures system stability and data integrity without altering the behavior of paginated queries.

Highlights

  • Pagination Logic Enhancement: Modified the find function in lib/core/find.js to refine how the size parameter is determined when pagination is disabled. This change ensures that a maximum result size is always applied, preventing potential issues with unbounded queries.
  • Default Max Size for Non-Paginated Queries: When paginate is set to false, the size parameter will now default to filters.$limit if provided, or to 10000 if filters.$limit is not specified. This provides a sensible upper bound for results when pagination is not in use.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where queries with paginate: false would be limited by Elasticsearch's default size by introducing a higher default limit in this scenario. My review includes a suggestion to improve maintainability by replacing the magic number 10000 with a named constant. More importantly, I've noted that the new logic is not covered by tests, and I strongly recommend adding test cases to verify the behavior for both when a $limit is provided with paginate: false and when it is not.

_source: filters.$select,
from: filters.$skip,
size: filters.$limit,
size: paginate === false ? filters.$limit || 10000 : filters.$limit, // Default max size to 10k if paginate is false

Choose a reason for hiding this comment

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

high

This change introduces new logic for when paginate is false, but it lacks corresponding unit tests. The file test/core/find.js should be updated to include test cases that verify this new behavior. Please add tests for the following scenarios:

  1. paginate: false is used without a $limit parameter.
  2. paginate: false is used with a $limit parameter.

_source: filters.$select,
from: filters.$skip,
size: filters.$limit,
size: paginate === false ? filters.$limit || 10000 : filters.$limit, // Default max size to 10k if paginate is false

Choose a reason for hiding this comment

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

medium

The number 10000 is a magic number. To improve readability and maintainability, it should be extracted into a named constant defined at the top of the file (e.g., const DEFAULT_MAX_FIND_SIZE = 10000;). Using a descriptive constant makes the code's intent clearer and simplifies future updates. With a well-named constant, the trailing comment is no longer necessary.

Suggested change
size: paginate === false ? filters.$limit || 10000 : filters.$limit, // Default max size to 10k if paginate is false
size: paginate === false ? filters.$limit || DEFAULT_MAX_FIND_SIZE : filters.$limit,

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.

1 participant