Conversation
Signed-off-by: Vaibhav Agarwal <vaibhoag@amazon.com>
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23035 +/- ##
============================================
+ Coverage 71.73% 71.75% +0.01%
+ Complexity 77670 77621 -49
============================================
Files 6168 6168
Lines 360106 360112 +6
Branches 52379 52380 +1
============================================
+ Hits 258314 258390 +76
+ Misses 81254 81164 -90
- Partials 20538 20558 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vaibhoag
marked this pull request as ready for review
September 15, 2026 08:16
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Returns HTTP 400 (
illegal_argument_exception) instead of HTTP 500 when a non-integer value is supplied formin_gram/max_gramin thengramandedge_ngramtokenizers and token filters.Gram sizes are character counts and must be integers. Today, a value such as
1.0— commonly produced by client-side JSON serializers that emit whole numbers as floats — is stored verbatim inSettingsand fails inSettings#getAsIntwith aSettingsException, which surfaces to the caller as an internal server error. That masks the actionable message and encourages clients to retry a request that can never succeed:Before:
500—OpenSearch exception [type=settings_exception, reason=Failed to parse int setting [min_gram] with value [1.0]]After:
400—illegal_argument_exception: [min_gram] must be an integer, got [1.0]Changes:
Settings#getAsIntStrict(String, Integer): identical togetAsIntfor absent and valid values, but throwsIllegalArgumentException(HTTP 400) naming the setting and the offending value when the value cannot be parsed as an integer. Intended for reads of caller-supplied values where the setting is defined to be integral.min_gram/max_gramreads inNGramTokenizerFactory,EdgeNGramTokenizerFactory,NGramTokenFilterFactory, andEdgeNGramTokenFilterFactory. Analysis components are built during index creation, so a malformed gram size now failsCreateIndexfast with a clear client error.Settings#getAsIntandSettingsExceptionsemantics are unchanged for all other callers; settings parse failures outside caller-supplied input keep their existing behavior.Testing:
SettingsTests#testGetAsIntStrict— absent/valid/unparseable values, and asserts the lenientgetAsIntstill throwsSettingsExceptionfor the same value.NGramTokenizerFactoryTests#testNonIntegerGramSizeIsClientError— end-to-end through the real tokenizer factory: asserts the exact message and theNumberFormatExceptioncause.Related Issues
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.