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 NPE getting metaFields from mapperService on a close index request #4497

Merged
merged 2 commits into from
Jun 30, 2024

Conversation

cwperks
Copy link
Member

@cwperks cwperks commented Jun 27, 2024

Description

Fixes a NullPointerException that occurs on a Closed index request. This fixes an issue seen after the merge of #4370 which made a change to get the list of metaFields from the mapperService in core. On close index requests, indexService.mapperService() can return null so the call to indexService.mapperService().getMetadataFields() throws an NPE.

mapperService would be null because needsMapperService would return false on closed index.

This fix checks for Close index requests and handles the scenario accordingly. Closed indices are not searchable so there's no need to have a list of metaFields for a closed index.

The close index API operation closes an index. Once an index is closed, you cannot add data to it or search for any data within the index.

Ref: https://opensearch.org/docs/latest/api-reference/index-apis/close-index/

  • Category

Bug fix

Issues Resolved

Check List

  • New functionality includes testing
  • New functionality has been documented
  • New Roles/Permissions have a corresponding security dashboards plugin PR
  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: Craig Perkins <[email protected]>
Copy link

codecov bot commented Jun 27, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 65.21%. Comparing base (6dedfb4) to head (0a6cde9).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4497      +/-   ##
==========================================
- Coverage   65.21%   65.21%   -0.01%     
==========================================
  Files         313      313              
  Lines       22047    22053       +6     
  Branches     3559     3561       +2     
==========================================
+ Hits        14378    14381       +3     
- Misses       5895     5897       +2     
- Partials     1774     1775       +1     
Files Coverage Δ
...figuration/SecurityFlsDlsIndexSearcherWrapper.java 91.66% <70.00%> (-5.96%) ⬇️

Copy link
Contributor

@shikharj05 shikharj05 left a comment

Choose a reason for hiding this comment

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

good catch, thank you fixing this!

@DarshitChanpura DarshitChanpura merged commit 34da6e8 into opensearch-project:main Jun 30, 2024
42 checks passed
@DarshitChanpura DarshitChanpura added the backport 2.x backport to 2.x branch label Jun 30, 2024
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/security/backport-2.x
# Create a new branch
git switch --create backport/backport-4497-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 34da6e86fbcdaf2b87a3dadf33e1c53e425b280e
# Push it to GitHub
git push --set-upstream origin backport/backport-4497-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-4497-to-2.x.

@cwperks
Copy link
Member Author

cwperks commented Jul 1, 2024

Creating a manual backport

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants