Skip to content

Range Validation#20518

Merged
andrross merged 27 commits intoopensearch-project:mainfrom
urmichm:20497-range-validation
Feb 12, 2026
Merged

Range Validation#20518
andrross merged 27 commits intoopensearch-project:mainfrom
urmichm:20497-range-validation

Conversation

@urmichm
Copy link
Copy Markdown
Contributor

@urmichm urmichm commented Feb 1, 2026

Description

Added range validation for the query builder and the field mapper.

Related Issues

Resolves #20497

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • Public documentation issue/PR created, if applicable.

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.

@github-actions github-actions bot added bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing labels Feb 1, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 1, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds strict validation for range bounds during indexing and query parsing, refactors range parsing into a dedicated method that handles CIDR/IP input and ignore_malformed, and adds tests plus a changelog entry. No public API signature changes.

Changes

Cohort / File(s) Summary
Range mapper implementation
server/src/main/java/org/opensearch/index/mapper/RangeFieldMapper.java
Refactors parsing into a private parseRange(ParseContext); validates single-assignment and inclusivity for bounds, supports CIDR IP strings, handles ignore_malformed, fills missing bounds with type min/max, and centralizes error handling. Adjusts when _field_names is created.
Range query parsing
server/src/main/java/org/opensearch/index/query/RangeQueryBuilder.java
Introduces nullable Boolean include flags, uses DeprecationHandler-aware parsing, enforces single-assignment and GT/GTE / LT/LTE consistency, adds explicit invalid-bound error messages, and applies include flags only when explicitly provided.
Mapper & Query tests
server/src/test/java/org/opensearch/index/mapper/RangeFieldMapperTests.java, server/src/test/java/org/opensearch/index/query/RangeQueryBuilderTests.java
Adds tests asserting parsing errors for conflicting/duplicate lower and upper bound configurations in both the mapper and the query builder (note: RangeFieldMapperTests contains duplicated test methods).
Changelog
CHANGELOG.md
Adds an Unreleased 3.x entry: "Add range validations in query builder and field mapper ([#20497])".

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Client
participant Parser as ParseContext / XContentParser
participant Mapper as RangeFieldMapper
participant Type as RangeType
rect rgba(220,220,255,0.5)
Client->>Parser: send JSON range input
Parser->>Mapper: parseRange(context)
Mapper->>Parser: read tokens (gt/gte/lt/lte, cidr, null)
alt CIDR string detected
Mapper->>Type: parseIpRangeFromCidr(...)
Type-->>Mapper: Range or error
else Object bounds
Mapper->>Type: rangeType.parseFrom/parseTo(...)
Type-->>Mapper: parsed bound values
end
Mapper->>Mapper: validate single-assignment & inclusivity
alt malformed and ignore_malformed
Mapper->>Mapper: record ignored field, return null
else valid
Mapper->>Type: rangeType.createFields(...)
Type-->>Mapper: Lucene fields
Mapper->>Parser: optionally create _field_names
end
end

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title "Range Validation" is overly vague and generic, using non-descriptive terms that do not clearly convey what specific change was made. Make the title more specific, e.g., "Add range validations in query builder and field mapper" or "Validate inclusive/exclusive bounds in range fields."
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is mostly complete with a clear description, linked issue reference, and checklist acknowledgment, though some optional sections remain unchecked.
Linked Issues check ✅ Passed The code changes successfully implement range validation for both query builder and field mapper to reject conflicting/invalid inclusive-exclusive bounds as required by issue #20497.
Out of Scope Changes check ✅ Passed All code changes are directly related to range validation requirements in issue #20497; changelog update is appropriate and no extraneous changes detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

❕ Gradle check result for 9a9b3a9: UNSTABLE

Please review all flaky tests that succeeded after retry and create an issue if one does not already exist to track the flaky failure.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 1, 2026

Codecov Report

❌ Patch coverage is 88.46154% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.37%. Comparing base (ac911ed) to head (cfd1fd1).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
.../org/opensearch/index/mapper/RangeFieldMapper.java 83.05% 5 Missing and 5 partials ⚠️
.../org/opensearch/index/query/RangeQueryBuilder.java 95.55% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #20518      +/-   ##
============================================
+ Coverage     73.28%   73.37%   +0.09%     
- Complexity    72143    72221      +78     
============================================
  Files          5798     5798              
  Lines        329791   329830      +39     
  Branches      47531    47545      +14     
============================================
+ Hits         241681   242023     +342     
+ Misses        68786    68419     -367     
- Partials      19324    19388      +64     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 1, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 1, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 1, 2026

❌ Gradle check result for a8697d1: 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?

@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 1, 2026

Regression
org.opensearch.action.admin.cluster.filecache.PruneFileCacheIT.testPruneCacheWithRealData

Error Message

java.lang.AssertionError: Should have pruned bytes

Stacktrace

java.lang.AssertionError: Should have pruned bytes
	at __randomizedtesting.SeedInfo.seed([CDE0C412E58D517C:374F261BFA2814E2]:0)
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.assertTrue(Assert.java:42)
.....

@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 2, 2026

org.opensearch.action.admin.cluster.filecache.PruneFileCacheIT.testPruneCacheWithRealData is a known flaky test -> #19724

@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 7, 2026

Hello, all tests passed, please review my PR
@msfroh @epugh @sandeshkr419

Updated the description for range validation in query builder and field mapper.

Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Copy link
Copy Markdown
Member

@sandeshkr419 sandeshkr419 left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for working on this @urmichm!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

❌ Gradle check result for 343cdbe: 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?

@asimmahmood1
Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 9, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

❌ Gradle check result for 343cdbe:

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?

Copy link
Copy Markdown
Contributor

@asimmahmood1 asimmahmood1 left a comment

Choose a reason for hiding this comment

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

LGTM! I think this the right approach and avoid abigious requests to complete.

I am wondering though, other than the change log note, is there another place in 3.6 release we can state something like in the release blog:

OS 3.6 now has more strict validation for range queries. When upgrading to OS 3.6, there is chance that previous request with ambiguous range queries, e.g. with lte and lt, multiple lt, users should fix those request before upgrading.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 9, 2026

❌ Gradle check result for 343cdbe: 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: Mikhail Urmich <32458509+urmichm@users.noreply.github.com>
@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 10, 2026

Thank you @asimmahmood1 @sandeshkr419 for approving the PR

Failed tests on the pipeline are related to FlightClientManagerTests, which is known for flaky tests (#19728 #18938)
I have resolved the conflict on README, could you re-trigger the build?

Failed test:
Test Result (1 failure / +1)
org.opensearch.arrow.flight.bootstrap.FlightClientManagerTests.testFailedClusterUpdateButSuccessfulDirectRequest

@sandeshkr419 sandeshkr419 reopened this Feb 10, 2026
@sandeshkr419 sandeshkr419 added the skip-diff-analyzer Maintainer to skip code-diff-analyzer check, after reviewing issues in AI analysis. label Feb 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

❌ Gradle check result for cfd1fd1: 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?

@github-actions
Copy link
Copy Markdown
Contributor

✅ Gradle check result for cfd1fd1: SUCCESS

@urmichm
Copy link
Copy Markdown
Contributor Author

urmichm commented Feb 11, 2026

@sandeshkr419 Gradle check succeeded ✅
Please check if PR can be merged before we get conflicts and rebase triggers a new gradle check 😅

@andrross andrross merged commit d7eb5e7 into opensearch-project:main Feb 12, 2026
83 of 102 checks passed
@urmichm urmichm deleted the 20497-range-validation branch February 12, 2026 09:19
tanyabti pushed a commit to tanyabti/OpenSearch that referenced this pull request Feb 24, 2026
…roject#20518)

Signed-off-by: Michael <urmich.m@gmail.com>
Signed-off-by: Mikhail Urmich <32458509+urmichm@users.noreply.github.com>
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com>
tanyabti pushed a commit to tanyabti/OpenSearch that referenced this pull request Feb 24, 2026
…roject#20518)

Signed-off-by: Michael <urmich.m@gmail.com>
Signed-off-by: Mikhail Urmich <32458509+urmichm@users.noreply.github.com>
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
Co-authored-by: Sandesh Kumar <sandeshkr419@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing skip-diff-analyzer Maintainer to skip code-diff-analyzer check, after reviewing issues in AI analysis.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Range fields validation

4 participants