Fix value parsing bug.#4095
Merged
LantaoJin merged 8 commits intoopensearch-project:mainfrom Aug 26, 2025
Merged
Conversation
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
yuancu
reviewed
Aug 21, 2025
| if (node.isNumber()) { | ||
| return node.doubleValue(); | ||
| } else if (node.isTextual()) { | ||
| return Double.parseDouble(node.textValue()); |
Collaborator
There was a problem hiding this comment.
Shall we throw a legible error if the text cannot be parsed as double?
If it already does so, please add such a test.
Contributor
Author
There was a problem hiding this comment.
The scheme restricts the written value to be able to be parsed into the specific type, otherwise an error will be reported. Therefore, this part of the code will definitely receive a field that can be parsed into a double type.
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
yuancu
reviewed
Aug 22, 2025
Comment on lines
+172
to
+174
| } else if (node.isTextual()) { | ||
| if (node.textValue().isEmpty()) { | ||
| return 0L; |
Collaborator
There was a problem hiding this comment.
Can you also include such cases in the tests?
Signed-off-by: Xinyu Hao <haoxinyu@amazon.com>
LantaoJin
approved these changes
Aug 26, 2025
opensearch-trigger-bot bot
pushed a commit
that referenced
this pull request
Aug 26, 2025
* fix parsing-value bug Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * add dataType IT Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * modify it Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * modify it Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix IT error Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix IT error Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix empty string->number 0 Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * add empty string test Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> --------- Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> (cherry picked from commit fff3e3a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
qianheng-aws
pushed a commit
that referenced
this pull request
Aug 26, 2025
* fix parsing-value bug * add dataType IT * modify it * modify it * fix IT error * fix IT error * fix empty string->number 0 * add empty string test --------- (cherry picked from commit fff3e3a) Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot
pushed a commit
that referenced
this pull request
Aug 29, 2025
* fix parsing-value bug Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * add dataType IT Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * modify it Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * modify it Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix IT error Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix IT error Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * fix empty string->number 0 Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> * add empty string test Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> --------- Signed-off-by: Xinyu Hao <haoxinyu@amazon.com> (cherry picked from commit fff3e3a) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Swiddis
pushed a commit
that referenced
this pull request
Oct 30, 2025
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Lantao Jin <ltjin@amazon.com> Fix value parsing bug. (#4095)
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
Problem:
Certain fields in JSON content were not correctly parsed when numeric or boolean values were represented as strings.
What I did:
Added
parseLongValue,parseDoubleValue, andparseBooleanValuemethods to safely handle:Numeric strings (e.g., "123" → 123)
Boolean strings ("true" → true; "false" → false)
Special Handling:
Empty string (
"") is parsed as:0 for numeric types (long, int, double, etc.)
false for boolean type
Related Issues
Resolves #3001
Check List
--signoffor-s.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.