nick-boss-tech opened a new pull request, #5202:
URL: https://github.com/apache/solr/pull/5202

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-18446
   
   ## What happens today
   
   **When a request carries a `collection` parameter that disagrees with the 
collection named in the URL path, HttpSolrCall routes by the parameter, so the 
request can be served by a collection it was not addressed to.**
   
   
[HttpSolrCall](https://github.com/nick-boss-tech/solr/blob/b73f03976fa17b857bc0a81bc8af2c6b1c31e0bb/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java)
 resolves the request's collection with the `collection` parameter taking 
precedence over the path. The ticket says the URL path alone should govern 
which collection receives a collection-scoped request; the parameter overriding 
it sends the work to a different collection than the URL names.
   
   ## What this change does
   
   **The URL path decides the collection, on the v1 and the V2 entry paths 
alike; the `collection` parameter no longer overrides the path the request was 
sent to.**
   
   
[HttpSolrCall.java](https://github.com/nick-boss-tech/solr/blob/7e0251ee029125152c4d1791660189ef1e9dea06/solr/core/src/java/org/apache/solr/servlet/HttpSolrCall.java)
 keeps routing path-scoped, and 
[V2HttpCall.java](https://github.com/nick-boss-tech/solr/blob/7e0251ee029125152c4d1791660189ef1e9dea06/solr/core/src/java/org/apache/solr/api/V2HttpCall.java)
 now resolves the collection from its path segment instead of the parameter. 
[HttpSolrCallCloudTest](https://github.com/nick-boss-tech/solr/blob/7e0251ee029125152c4d1791660189ef1e9dea06/solr/core/src/test/org/apache/solr/servlet/HttpSolrCallCloudTest.java)
 covers the v1 disagreement case, the narrowing case, and the V2 disagreement 
case. Four existing tests that relied on the parameter winning 
(BasicDistributedZkTest, TestDistribIDF, 
RuleBasedAuthorizationCoreCollectionTest, 
DistributedQueryComponentOptimizationTest) now put their collections in the 
path, and AliasIntegrationTest keeps a case where a CloudSolrClient carries the 
col
 lection only as a parameter, which the client moves into the path. The Ref 
Guide's distributed-requests page now describes the parameter as narrowing the 
path, and the Solr 11 major-changes page records the removal. Eleven files 
change, including the changelog entry.
   
   ## Proof
   
   **The new V2 coverage failed before its fix and passes at this head; the 
checks below ran on this exact tree, verified 2026-10-22.**
   
   - Before the V2 fix, the new V2 case failed with `expected:<[collection1]> 
but was:<[collection2]>` (the parameter winning on the V2 path); the other four 
HttpSolrCallCloudTest tests passed.
   - At this head, seed 18446: HttpSolrCallCloudTest 5 run, 
AliasIntegrationTest 9 run, BasicDistributedZkTest 1 run (its monolithic test, 
which includes the multi-collection section), and the multi-collection methods 
of TestDistribIDF, RuleBasedAuthorizationCoreCollectionTest, and 
DistributedQueryComponentOptimizationTest 1 run each: 18 run, 0 skipped, 0 
failures.
   - The changelog entry parses, the Error Prone compile passes, and 
:solr:core:check -x test passes. Tidy reformatted two test files; the changes 
are formatting only and are committed on the branch.
   
   ## Limits
   
   **Requests whose parameter matches their path route as before. Three cases 
change: a parameter that disagrees with the path, a request with no collection 
in the path, and a multi-collection path with a non-matching parameter.**
   
   - The precedence change is deliberate and is what the ticket asks for. A 
client that relied on overriding the path with the `collection` parameter will 
now be routed by the path.
   - A request with no collection segment in the path, such as 
`/solr/select?collection=c1`, now returns 404 instead of routing by the 
parameter.
   - When the path names several collections (an alias or a comma list), the 
parameter only narrows the list; a parameter that matches none of them is 
ignored and the request goes to all of them.
   
   Changelog: 
[changelog/unreleased/SOLR-18446-path-controls-collection-routing.yml](https://github.com/nick-boss-tech/solr/blob/7e0251ee029125152c4d1791660189ef1e9dea06/changelog/unreleased/SOLR-18446-path-controls-collection-routing.yml)
   
   *AI-generated description. Nick Shanin directed the work and takes 
responsibility for this contribution.*


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to