-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix from and size parameter can be negative when searching #13047
Conversation
Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: Gao Binlong <[email protected]>
Compatibility status:Checks if related components are compatible with change 5689fe5 Incompatible componentsSkipped componentsCompatible componentsCompatible components: [https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/flow-framework.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/performance-analyzer.git, https://github.com/opensearch-project/sql.git] |
❌ Gradle check result for 35e0d3c: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Gao Binlong <[email protected]>
❌ Gradle check result for 644fd96: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Signed-off-by: Gao Binlong <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13047 +/- ##
===========================================
Coverage 71.42% 71.42%
- Complexity 59978 60639 +661
===========================================
Files 4985 5039 +54
Lines 282275 285426 +3151
Branches 40946 41336 +390
===========================================
+ Hits 201603 203878 +2275
- Misses 63999 64727 +728
- Partials 16673 16821 +148 ☔ View full report in Codecov by Sentry. |
server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Gao Binlong <[email protected]>
Signed-off-by: Gao Binlong <[email protected]>
server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java
Show resolved
Hide resolved
Signed-off-by: Gao Binlong <[email protected]>
@reta, could you help to review this PR, thanks! |
I have very limited availability this week, I will try to find the time, sorry about that @gaobinlong |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM.
server/src/main/java/org/opensearch/search/builder/SearchSourceBuilder.java
Show resolved
Hide resolved
@gaobinlong Is there a scenario with size=0 is also an issue? Would you mind taking a look? |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch/backport-2.x
# Create a new branch
git switch --create backport/backport-13047-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ab7e914c3956ac206cf269ca345574882770a283
# Push it to GitHub
git push --set-upstream origin backport/backport-13047-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch/backport-2.x Then, create a pull request where the |
@gaobinlong please be so kind to manually backport to 2.x? |
size=0 is a valid use case, which returns total hits count but not return the documents:
Response:
|
…h-project#13047) * Fix from and size parameter can be negative when searching Signed-off-by: Gao Binlong <[email protected]> * Add changelog Signed-off-by: Gao Binlong <[email protected]> * fix test failure Signed-off-by: Gao Binlong <[email protected]> * Fix test failure Signed-off-by: Gao Binlong <[email protected]> * Optimize the code Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]> (cherry picked from commit ab7e914)
Care to double check we have a test for it? Thanks. |
Yeah, there're multiple places that test OpenSearch/rest-api-spec/src/main/resources/rest-api-spec/test/scroll/10_basic.yml Line 230 in 9e9ab6b
and |
…hing (#13047) (#13361) * Fix from and size parameter can be negative when searching (#13047) * Fix from and size parameter can be negative when searching Signed-off-by: Gao Binlong <[email protected]> * Add changelog Signed-off-by: Gao Binlong <[email protected]> * fix test failure Signed-off-by: Gao Binlong <[email protected]> * Fix test failure Signed-off-by: Gao Binlong <[email protected]> * Optimize the code Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]> (cherry picked from commit ab7e914) * Update support version Signed-off-by: Gao Binlong <[email protected]> * Small change to rerun gradle check Signed-off-by: Gao Binlong <[email protected]> --------- Signed-off-by: Gao Binlong <[email protected]>
Description
This PR fixes the bug of the
from
andsize
parameter in search api can be negative which can cause 500 error when searching, the cause of this bug is that we don't validate the two parameters specified in the request body, but if the two parameters are specified in the URL path, they would be validated. Even thoughfrom
andsize
specified in the URL path will be validated, but because the default value of them are-1
, currently we allow users to set them to-1
which is equivalent to0
, this PR also changes this behavior,-1
is not allowed to set for the two parameters.Related Issues
#11290
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.