Use GetMappingsRequest instead of GetIndexRequest in QueryPlanningTool#4785
Use GetMappingsRequest instead of GetIndexRequest in QueryPlanningTool#4785owaiskazi19 wants to merge 2 commits intoopensearch-project:mainfrom
Conversation
PR Reviewer Guide 🔍(Review updated until commit 00b97d2)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 00b97d2 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 702c3c0
Suggestions up to commit 16120a8
Suggestions up to commit adda5de
|
|
Persistent review updated to latest commit 16120a8 |
QueryPlanningTool only needs index mappings but was using GetIndexRequest which requires the broader indices:admin/get permission. This change switches to GetMappingsRequest which only requires indices:admin/mappings/get, following the principle of least privilege and aligning with how other tools (knn, query_assistant) request mappings. Signed-off-by: Owais Kazi <owaiskazi19@gmail.com>
16120a8 to
702c3c0
Compare
|
Persistent review updated to latest commit 702c3c0 |
rithinpullela
left a comment
There was a problem hiding this comment.
Thanks for the PR Owais!
|
Persistent review updated to latest commit 00b97d2 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4785 +/- ##
=========================================
Coverage 77.41% 77.41%
- Complexity 11900 11901 +1
=========================================
Files 963 963
Lines 53310 53309 -1
Branches 6500 6500
=========================================
+ Hits 41268 41269 +1
- Misses 9287 9289 +2
+ Partials 2755 2751 -4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
QueryPlanningToolusesGetIndexRequestto retrieve index mappings for query planning, but it only accesses.mappings()from the response.GetIndexRequestrequires theindices:admin/getpermission, which also exposes index settings, aliases, and defaults — none of which QPT uses.This PR switches to
GetMappingsRequest/GetMappingsResponse, which only requiresindices:admin/mappings/get. This:knn_full_accessandquery_assistant_accessroles already handle mapping retrievalml_full_accessrole to support Agentic Search (QueryPlanningTool) with the narrowerindices:admin/mappings/getpermission instead of the broaderindices:admin/getRelated Issue
Resolves #4775
Changes
QueryPlanningTool.java:GetIndexRequest→GetMappingsRequestGetIndexResponse→GetMappingsResponseclient.admin().indices().getIndex()→client.admin().indices().getMappings().mappings()returns the sameMap<String, MappingMetadata>QueryPlanningToolTests.java:GetMappingsResponseindicesAdminClient.getIndex()→indicesAdminClient.getMappings()Check List
--signoff