Skip to content
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 array_index_out_of_bounds_exception when indexing documents with field name containing only dot #15126

Merged
merged 3 commits into from
Aug 9, 2024

Conversation

gaobinlong
Copy link
Collaborator

@gaobinlong gaobinlong commented Aug 6, 2024

Description

"." as field name yields array_index_out_of_bounds_exception, the reason is that we split the field name by . here:

String[] parts = fullFieldPath.split("\\.");
,
, if the field name contains only dot, the split result is an empty array, then yields that exception in this line:
return objectMapper.getMapper(subfields[subfields.length - 1]);
.

Since . is reserved for object resolution, we can fail the indexing request when the field name contains only dot.

Related Issues

Resolves #14911

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.

…field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: Gao Binlong <gbinlong@amazon.com>
@gaobinlong gaobinlong added the backport 2.x Backport to 2.x branch label Aug 6, 2024
Copy link
Contributor

github-actions bot commented Aug 6, 2024

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

Copy link
Contributor

github-actions bot commented Aug 6, 2024

✅ Gradle check result for 778f159: SUCCESS

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.73%. Comparing base (49b7cd4) to head (2e4fdf5).
Report is 12 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #15126      +/-   ##
============================================
- Coverage     71.84%   71.73%   -0.11%     
+ Complexity    62820    62701     -119     
============================================
  Files          5169     5169              
  Lines        294664   294666       +2     
  Branches      42615    42616       +1     
============================================
- Hits         211691   211386     -305     
- Misses        65530    65820     +290     
- Partials      17443    17460      +17     

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

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Copy link
Contributor

github-actions bot commented Aug 8, 2024

✅ Gradle check result for 2e4fdf5: SUCCESS

@gaobinlong
Copy link
Collaborator Author

@reta, mind taking a second look at this PR? Thank you!

@reta
Copy link
Collaborator

reta commented Aug 9, 2024

Thanks a lot, @gaobinlong !

@reta reta added v3.0.0 Issues and PRs related to version 3.0.0 v2.17.0 labels Aug 9, 2024
@reta reta merged commit 252742b into opensearch-project:main Aug 9, 2024
43 of 44 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 9, 2024
…field name containing only dot (#15126)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Optimize error message

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
(cherry picked from commit 252742b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
reta added a commit that referenced this pull request Aug 9, 2024
…documents with field name containing only dot (#15188)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot (#15126)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Optimize error message

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
(cherry picked from commit 252742b)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* Update 120_field_name.yml

Signed-off-by: Andriy Redko <andriy.redko@aiven.io>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Andriy Redko <andriy.redko@aiven.io>
harshavamsi pushed a commit to harshavamsi/OpenSearch that referenced this pull request Aug 20, 2024
…field name containing only dot (opensearch-project#15126)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Optimize error message

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
wdongyu pushed a commit to wdongyu/OpenSearch that referenced this pull request Aug 22, 2024
…field name containing only dot (opensearch-project#15126)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Optimize error message

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
akolarkunnu pushed a commit to akolarkunnu/OpenSearch that referenced this pull request Sep 10, 2024
…field name containing only dot (opensearch-project#15126)

* Fix array_index_out_of_bounds_exception when indexing documents with field name containing only dot

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Modify change log

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

* Optimize error message

Signed-off-by: Gao Binlong <gbinlong@amazon.com>

---------

Signed-off-by: Gao Binlong <gbinlong@amazon.com>
@gaobinlong gaobinlong deleted the fieldName branch September 18, 2024 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing v2.17.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] "." as field name yields array_index_out_of_bounds_exception
3 participants