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 ClassCastException when using dynamic template with flat_object mapping and dots in field names #13081

Closed
wants to merge 2 commits into from

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Apr 4, 2024

Description

Opening a draft PR to solicit feedback. This fixes an issue that can cause the DocumentParser to throw a ClassCastException when there is a dynamic template with a flat_object mapping and trying to index a document that contains field names with dots.

Instead of the ClassCastException, this PR will still fail the request but with a more descriptive error message saying that dots in field names is forbidden using a dynamic template with flat_object mapping. This is similar to existing behavior with dynamic templates with a nested mapping. See similar test.

Related Issues

Resolves #12298

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Failing checks are inspected and point to the corresponding known issue(s) (See: Troubleshooting Failing Builds)
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)
  • Public documentation issue/PR created

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.

…apping and dots in field names

Signed-off-by: Craig Perkins <[email protected]>
@github-actions github-actions bot added bug Something isn't working Indexing Indexing, Bulk Indexing and anything related to indexing labels Apr 4, 2024
Signed-off-by: Craig Perkins <[email protected]>
@reta
Copy link
Collaborator

reta commented Apr 4, 2024

@cwperks it supposed to be fixed by #11425, tldr;' the field names with dots should be handled properly I believe, if it is not the case - the previous fix looks incomplete, @msfroh fyi

@cwperks
Copy link
Member Author

cwperks commented Apr 4, 2024

@reta I can reproduce the issue described in #12298 using the steps provided. The test I wrote will also throw the ClassCastException without the corresponding change in DocumentParser.java.

Copy link
Contributor

github-actions bot commented Apr 4, 2024

Compatibility status:

Checks if related components are compatible with change fce90d2

Incompatible components

Skipped components

Compatible components

Compatible components: [https://github.com/opensearch-project/custom-codecs.git, https://github.com/opensearch-project/asynchronous-search.git, https://github.com/opensearch-project/neural-search.git, https://github.com/opensearch-project/flow-framework.git, https://github.com/opensearch-project/reporting.git, https://github.com/opensearch-project/cross-cluster-replication.git, https://github.com/opensearch-project/job-scheduler.git, https://github.com/opensearch-project/security-analytics.git, https://github.com/opensearch-project/opensearch-oci-object-storage.git, https://github.com/opensearch-project/geospatial.git, https://github.com/opensearch-project/notifications.git, https://github.com/opensearch-project/common-utils.git, https://github.com/opensearch-project/k-nn.git, https://github.com/opensearch-project/observability.git, https://github.com/opensearch-project/anomaly-detection.git, https://github.com/opensearch-project/ml-commons.git, https://github.com/opensearch-project/alerting.git, https://github.com/opensearch-project/performance-analyzer-rca.git, https://github.com/opensearch-project/index-management.git, https://github.com/opensearch-project/sql.git, https://github.com/opensearch-project/security.git, https://github.com/opensearch-project/performance-analyzer.git]

@reta
Copy link
Collaborator

reta commented Apr 4, 2024

@reta I can reproduce the issue described in #12298 using the steps provided. The test I wrote will also throw the ClassCastException without the corresponding change in DocumentParser.java.

@cwperks sure, the issue is there, the fix was incomplete?

Copy link
Contributor

github-actions bot commented Apr 4, 2024

❌ Gradle check result for b886c7e: 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 Apr 4, 2024

❕ Gradle check result for fce90d2: UNSTABLE

  • TEST FAILURES:
      1 org.opensearch.index.shard.RemoteIndexShardTests.testNRTReplicaWithRemoteStorePromotedAsPrimaryCommitCommit

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

Copy link

codecov bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.48%. Comparing base (b15cb0c) to head (fce90d2).
Report is 133 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #13081      +/-   ##
============================================
+ Coverage     71.42%   71.48%   +0.06%     
- Complexity    59978    60462     +484     
============================================
  Files          4985     5026      +41     
  Lines        282275   284456    +2181     
  Branches      40946    41197     +251     
============================================
+ Hits         201603   203350    +1747     
- Misses        63999    64311     +312     
- Partials      16673    16795     +122     

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

@cwperks
Copy link
Member Author

cwperks commented Apr 4, 2024

Closing this PR in favor of revisiting #11425 for completeness. Thank you @reta!

@cwperks cwperks closed this Apr 4, 2024
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] dynamic_template throws class_cast_exception
2 participants