Repository navigation
[Ready] SOLR-18129: Keep multi-valued request-handler defaults, appends and invariants on the Config API - #5000
Draft
nick-boss-tech wants to merge 10 commits into
Draft
nick-boss-tech wants to merge 10 commits into
nick-boss-tech wants to merge 10 commits into
Conversation
Join the over-wrapped defaults-map line per palantir-java-format.
The duplicate-key accumulation for defaults/appends/invariants covered add-requesthandler and update-requesthandler, but create-requesthandler fell through to last-wins, contradicting the documented behavior that repeated parameter names are folded into a list. Include the create command in REQUEST_HANDLER_COMMANDS and cover it with testRequestHandlerMultiValuedDefaultsOnCreate.
nick-boss-tech
marked this pull request as draft
October 28, 2026 04:25
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖 (posted on behalf of Nick Shanin)
Ready for review, but held as a draft due to the project's open-PR cap; I'll mark it open on request.
https://issues.apache.org/jira/browse/SOLR-18129
What happens today
The Config API keeps only the last value when a request-handler section repeats a key.
update-requesthandlervia the Config API is broken for multi-valued parameters. When a request handler'sdefaults,appends, orinvariantssection repeats a key (the JSON form of a multi-valued parameter), the command parser keeps only the last value and silently drops the rest. A handler configured through the API ends up with a single value where the configuration asked for several, with no error.What this change does
Duplicate keys in the
defaults,appends, andinvariantssections of the three request-handler commands now accumulate into lists instead of collapsing.CommandOperationnow parses the request-handler commands with an accumulating object builder, so duplicate keys inside thedefaults,appends, andinvariantssections accumulate into lists instead of collapsing, andnormalizeCommandDatakeeps those sections multi-valued for theadd-requesthandler,update-requesthandler, andcreate-requesthandlercommands. The accumulation is scoped to those commands and those sections; every other command keeps the previous last-value-wins behavior for duplicate keys. The ref guide's config-api page documents the behavior.Proof
Both test classes pass at the head, and on base production code the focused tests fail at the test step.
Verified at head 657e443 on 2026-10-06 (a changelog-title-only change on top of f571596):
TestUtils20 of 20 andTestSolrConfigHandler13 of 13 pass (the class has 13 test methods), from the focused run at this head, with:solr:core:checkpassing. TestUtils also passed on the fork's GitHub Actions runner on this code (run 37569145964, CI commit19f7433f7a7, 2026-10-06; that commit adds only the workflow file). The array-form tests are part of the focused counts above. The same test classes were also run against base production code with this PR's test files.TestUtils: 20 of 20 pass with this change.TestSolrConfigHandler: 13 of 13 pass with this change. End to end, create is covered for all three sections and update fordefaults;appendsandinvariantsupdates are covered at the parser level inTestUtils, where all three sections useupdate-requesthandler.The array-of-commands form (a JSON array of command objects under one command name) is covered at the parser level in
TestUtilsand end to end inTestSolrConfigHandler. A guard test inTestUtilschecks that other commands keep last-value-wins in list form. On base production code the focused tests fail at the test step. An earlier state of this branch (CI commit61527cf7f76, 2026-10-04, before the list-form commit) passed in GitHub runs 37225864392 and 37225860272.A choice to check
The parser accumulates duplicate keys instead of rejecting them or staying strict with arrays documented only.
One fact first: sending the values as a JSON array already works today, on base code as well as with this change, and the ref guide text in this PR calls arrays the portable encoding. So no user is without a way to send several values; the question is only what a repeated key should do.
This PR makes the shared Config API parser accumulate duplicate keys, scoped to the request-handler sections above. The cost of that route is about 120 lines added in
CommandOperation, a solrj class that every command API parses through, with the three command names and the three section names hard-coded in the parser. Every payload parsed throughCommandOperation.parsealso goes through the new normalization pass:normalizeCommandDatawalks each command's data andcollapseDuplicateKeyswalks the parts that do not accumulate, mutating the parsed maps and lists in place. That extra tree walk is intentional, and it applies to every Config API command, not only the three request-handler ones; it changes values only where duplicate keys were recorded, but the walk itself is unconditional. The other routes were to reject duplicate keys with an error, or to leave the parser strict and document arrays only. I chose accumulating over rejecting because payloads that repeat these keys are silently truncated today; rejecting would make them start failing outright, while accumulating gives them the values the sender plainly listed. If you would rather the parser stay strict, I can reduce this to the documentation route instead. Was accumulating the right call, or should the parser stay strict and document arrays only?Limits
Only the three request-handler commands and their three sections accumulate; everything else keeps last-value-wins.
Only the three request-handler commands and their
defaults/appends/invariantssections accumulate duplicate keys. Nested structures deeper than those sections are not treated specially. A client that relied on last-value-wins inside these sections (for example a templated payload where a later key overrides an earlier one) now gets both values. A repeated section itself, twodefaultsobjects in one command, is not merged; the last one wins. A repeated key whose values mix an array and a scalar is flattened into one list; no test covers that mix.add-initparamsandupdate-initparamsaccept the same three section names and still drop repeated keys. The v2 Config endpoint parses through the same code and accumulates too; the end-to-end tests post to/configon v1 only. Accumulating duplicate keys for every Config API command would be a broader change; it is not done here, and I can open a ticket for it if you would like it tracked.Changelog: changelog/unreleased/SOLR-18129.yml (fixed)
AI assistance
AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution.