Preserve multi-value request params through PathTrie iteration#145223
Preserve multi-value request params through PathTrie iteration#145223felixbarny merged 4 commits intoelastic:mainfrom
Conversation
RestController#getAllHandlers was using Map.copyOf(requestParamsRef) to snapshot the original params before PathTrie iterations. Map.copyOf only sees the last value per key (via entrySet), silently dropping earlier values for repeated parameters like ?format=json&format=yaml. - Add RequestParams.copyOf(RequestParams) to deep-copy all multi-values - Add RequestParams.putAll(RequestParams) overload that copies every value in each key's list, unlike the inherited putAll(Map) which only sees the last value per key via entrySet - Change getAllHandlers to accept RequestParams instead of Map<String,String> and use the new methods - Add tests for copyOf, putAll(RequestParams), and a regression test in RestControllerTests
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
|
Pinging @elastic/es-distributed (Team:Distributed) |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughTwo new utility methods were added to RequestParams: ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsTimed out fetching pipeline failures after 30000ms Comment |
Re-parses the raw URI via RequestParams.fromUri to capture all repeated match[] values, working around the current limitation where request processing keeps only the last value for repeated parameters (tracked in elastic#145223). Also calls repeatedParamAsList to mark the parameter as consumed so Elasticsearch does not reject the request as having unrecognized params. Adds IT test cases for all three endpoints (labels, label values, series) that send two match[] selectors and verify only the matched series contribute to the response.
…45298) Re-parses the raw URI via RequestParams.fromUri to capture all repeated match[] values, working around the current limitation where request processing keeps only the last value for repeated parameters (tracked in #145223). Also calls repeatedParamAsList to mark the parameter as consumed so Elasticsearch does not reject the request as having unrecognized params. Adds IT test cases for all three endpoints (labels, label values, series) that send two match[] selectors and verify only the matched series contribute to the response.
… params Now that RestRequest preserves multi-value request parameters, remove the workaround that re-parsed match[] from the raw URI via RequestParams.fromUri().
…astic#145298) Re-parses the raw URI via RequestParams.fromUri to capture all repeated match[] values, working around the current limitation where request processing keeps only the last value for repeated parameters (tracked in elastic#145223). Also calls repeatedParamAsList to mark the parameter as consumed so Elasticsearch does not reject the request as having unrecognized params. Adds IT test cases for all three endpoints (labels, label values, series) that send two match[] selectors and verify only the matched series contribute to the response.
RestController#getAllHandlerswas usingMap.copyOf(requestParamsRef)to snapshot the original params before PathTrie iterations.Map.copyOfonly sees the last value per key (viaentrySet), silently dropping earlier values for repeated parameters like?format=json&format=yaml.getAllHandlersto acceptRequestParamsinstead ofMap<String, String>RequestParams.copyOf(RequestParams)to deep-copy all multi-valuesRequestParams.putAll(RequestParams)overload that copies every value in each key's list, unlike the inheritedputAll(Map)which only sees the last value per key viaentrySetcopyOf,putAll(RequestParams), and a regression test inRestControllerTestsFollow-up from #144506