Skip to content

Conversation

@buddharajusahil
Copy link
Contributor

@buddharajusahil buddharajusahil commented Dec 9, 2025

Description

This change is adding a public getter function for the excludes list in SourceFieldMapper.

Related Issues

Resolves #20201

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.

Summary by CodeRabbit

  • New Features

    • Added a public API method to read an index source field's exclusion settings so external tools can access configured excludes.
  • Chores

    • Release notes updated to reference the new public getter in the API surface.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 9, 2025

Walkthrough

Added a public accessor getExcludes() to SourceFieldMapper that returns a cloned copy of the private excludes array, exposing the excludes configuration as a public API without changing other behavior.

Changes

Cohort / File(s) Change Summary
SourceFieldMapper API Expansion
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java
Added public String[] getExcludes() which returns a clone of the existing private excludes array, exposing excludes externally while avoiding direct mutation of the original array.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify method signature and visibility (public String[] getExcludes()).
  • Confirm it returns a defensive clone (not the original array) and does not mutate state.
  • Check import/style and javadoc or comment consistency.

Poem

🐇 I dug a tiny tunnel through the code,
Found hidden hops the mapper owed,
I return a copy, neat and bright,
Excludes now step into the light,
A gentle tweak — the repo's delight.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: adding a public getter function for the source field mapper excludes.
Description check ✅ Passed The description follows the template with all key sections completed: a clear description of the change, linked issue reference, and completed checklist for testing and documentation.
Linked Issues check ✅ Passed The code changes fulfill the objective stated in issue #20201 by adding a public getter method getExcludes() to SourceFieldMapper, enabling efficient retrieval of excludes as required.
Out of Scope Changes check ✅ Passed All changes in this PR are directly in scope: only a single public getter method was added to SourceFieldMapper to address the feature request, with no extraneous modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)

285-287: Accessor implementation is correct; consider defensive copy if immutability is desired

The new getExcludes() correctly exposes the configured excludes and aligns with the stated PR goal; no functional issues here. The only consideration is that returning the backing String[] allows callers to mutate the array contents and effectively change the mapper’s internal state. If you want to keep SourceFieldMapper effectively immutable, you could instead return a copy or an unmodifiable view:

-    public String[] getExcludes() {
-        return excludes;
-    }
+    public String[] getExcludes() {
+        return Arrays.copyOf(excludes, excludes.length);
+    }

This is optional and depends on how much you want to protect against external mutation of mapper configuration.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba9ec47 and 9100f2c.

📒 Files selected for processing (1)
  • server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: gradle-check
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: precommit (21, macos-15-intel)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, windows-latest)
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: detect-breaking-change
  • GitHub Check: Analyze (java)

@buddharajusahil buddharajusahil force-pushed the feature/source-excludes-public branch from 9100f2c to 0b686af Compare December 9, 2025 23:26
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)

285-287: Avoid leaking internal excludes array; return a defensive copy instead

Returning the backing String[] lets callers mutate internal state of a SourceFieldMapper, which can violate immutability assumptions and cause hard‑to‑trace bugs under concurrent access. Consider returning a copy instead.

-    public String[] getExcludes() {
-        return excludes;
-    }
+    public String[] getExcludes() {
+        return excludes.clone();
+    }
CHANGELOG.md (1)

40-40: Changelog entry correctly documents the new public getter

The new bullet accurately reflects the SourceFieldMapper API change; no functional concerns. If you want to polish wording, consider “…for use with k‑NN derived source paths” for slightly smoother phrasing.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9100f2c and 0b686af.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
  • GitHub Check: gradle-check
  • GitHub Check: Analyze (java)
  • GitHub Check: precommit (25, macos-15-intel)
  • GitHub Check: assemble (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, macos-15)
  • GitHub Check: precommit (25, ubuntu-24.04-arm)
  • GitHub Check: precommit (21, windows-2025, true)
  • GitHub Check: assemble (25, windows-latest)
  • GitHub Check: precommit (21, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-24.04-arm)
  • GitHub Check: precommit (25, ubuntu-latest)
  • GitHub Check: precommit (25, windows-latest)
  • GitHub Check: precommit (21, macos-15-intel)
  • GitHub Check: precommit (21, ubuntu-24.04-arm)
  • GitHub Check: assemble (25, ubuntu-latest)
  • GitHub Check: assemble (21, ubuntu-latest)
  • GitHub Check: assemble (21, windows-latest)
  • GitHub Check: precommit (21, windows-latest)
  • GitHub Check: precommit (21, macos-15)
  • GitHub Check: detect-breaking-change

}

public String[] getExcludes() {
return excludes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets return immutable version of excludes something like

public List<String> getArray() {
    return List.of(excludes);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, can we do excludes.clone()? To avoid changing the return type.

@github-actions
Copy link
Contributor

✅ Gradle check result for 0b686af: SUCCESS

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.22%. Comparing base (9f8d381) to head (a4f4556).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...org/opensearch/index/mapper/SourceFieldMapper.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #20205      +/-   ##
============================================
- Coverage     73.30%   73.22%   -0.09%     
+ Complexity    71804    71718      -86     
============================================
  Files          5793     5793              
  Lines        328160   328174      +14     
  Branches      47266    47267       +1     
============================================
- Hits         240559   240290     -269     
- Misses        68295    68622     +327     
+ Partials      19306    19262      -44     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Signed-off-by: Sahil Buddharaju <sahilbud@amazon.com>
@buddharajusahil buddharajusahil force-pushed the feature/source-excludes-public branch from 0b686af to a4f4556 Compare December 10, 2025 02:24
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1)

285-287: Defensive copy via clone() is correct; consider documenting contract

Returning excludes.clone() cleanly exposes the configuration without leaking internal mutable state, and keeps the existing String[]-based API surface intact. From a correctness and encapsulation standpoint this looks good.

As a minor follow‑up, consider adding brief Javadoc on getExcludes() clarifying that:

  • it never returns null, and
  • it returns a copy of the excludes array that callers are free to modify.

That will help future users of this public API understand the method’s guarantees.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0b686af and a4f4556.

📒 Files selected for processing (2)
  • CHANGELOG.md (1 hunks)
  • server/src/main/java/org/opensearch/index/mapper/SourceFieldMapper.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: gradle-check

@github-actions
Copy link
Contributor

❕ Gradle check result for a4f4556: UNSTABLE

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement or improvement to existing feature or request _No response_

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Make excludes publicly accessible in SourceFieldMapper

2 participants