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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-8240
   
   ## What happens today
   
   **A request to `/update/json/docs` that sets `mapUniqueKeyOnly=true` and 
also sends field mappings (`f`) succeeds, and the names in `f` are dropped.**
   
   With `mapUniqueKeyOnly=true`, each record keeps only its uniqueKey and the 
`srcField` copy. Every other mapped value goes into the default search field 
(`df`) with no field name ([mapping code at the base 
commit](https://github.com/nick-boss-tech/solr/blob/e432df19c4a50b9d54d7fba545397b859cc54f98/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java#L295-L327)).
 A request with `f=title:/title` puts the title text into `df` and returns 
success. The name `title` never reaches the index.
   
   ## What this change does
   
   **A request that sends `f` with `mapUniqueKeyOnly=true` now fails with a 400 
error.**
   
   The check runs first in `handleSplitMode`, before any record is read 
([check](https://github.com/nick-boss-tech/solr/blob/fad7a1dd8e2397330e0973e809aeba60490d2f08/solr/core/src/java/org/apache/solr/handler/loader/JsonLoader.java#L249-L255)).
 The error text tells the caller to send `mapUniqueKeyOnly=false` to map 
fields. The reference guide documents the rule 
([guide](https://github.com/nick-boss-tech/solr/blob/fad7a1dd8e2397330e0973e809aeba60490d2f08/solr/solr-ref-guide/modules/indexing-guide/pages/transforming-and-indexing-custom-json.adoc#L68)).
   
   The check reads the effective value, so an inherited value counts. A params 
set or `initParams` that sets `mapUniqueKeyOnly=true` makes each request that 
sends `f` fail, unless the request sends `mapUniqueKeyOnly=false`. The 
techproducts sample sets it for `/update/json/docs` 
([params.json](https://github.com/nick-boss-tech/solr/blob/fad7a1dd8e2397330e0973e809aeba60490d2f08/solr/server/solr/configsets/sample_techproducts_configs/conf/params.json#L3-L5)).
 Until [SOLR-10424](https://issues.apache.org/jira/browse/SOLR-10424) removes 
that default, `f` requests to the sample fail with this error.
   
   ## A choice to check
   
   **The request now fails, where the old code let it succeed and drop the 
names.**
   
   The options are:
   
   1. Return a 400 when `f` and `mapUniqueKeyOnly=true` both apply. This is the 
change here. The ticket proposes this error.
   2. Accept the request and report the unused `f` in the response or the log. 
Clients keep working, but the names are still dropped.
   
   Option 1 costs a new error for clients that send both, or inherit the value. 
Option 2 keeps those requests working, but the mismatch stays a warning.
   
   Was the 400 the right call?
   
   ## Limits
   
   **The test covers a request that sets the value itself, and the reference 
guide page is not updated here.**
   
   - The new test covers a request that sets the value itself. It does not 
cover an inherited value.
   - The "Setting JSON Defaults" section of the same reference guide page still 
shows `mapUniqueKeyOnly` as a default. A request that uses that default and 
sends `f` gets the 400. This change does not edit that section. Updating it is 
a planned follow-up pull request.
   
   Changelog: 
[`changelog/unreleased/SOLR-8240-map-unique-key-only-f-conflict.yml`](https://github.com/nick-boss-tech/solr/blob/fad7a1dd8e2397330e0973e809aeba60490d2f08/changelog/unreleased/SOLR-8240-map-unique-key-only-f-conflict.yml)
   
   ## Proof
   
   **JsonLoaderTest passes 32 of 32 and TestInitParams passes 7 of 7 at this 
head. The new test fails on the code before this change.**
   
   - `JsonLoaderTest.testFieldMappingWithMapUniqueKeyOnlyIsRejected` 
([test](https://github.com/nick-boss-tech/solr/blob/fad7a1dd8e2397330e0973e809aeba60490d2f08/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java#L192-L214))
 sends `f=title:/title` with `mapUniqueKeyOnly=true`. It expects a 400 whose 
message names `mapUniqueKeyOnly`.
   - On the code before this change, the test fails with "Expected exception 
SolrException but no exception was thrown".
   - Counts at `fad7a1dd8e23`: JsonLoaderTest 32 of 32, TestInitParams 7 of 7. 
Verified 2026-10-05 at this head.
   
   ### AI assistance
   
   AI agents assisted with research, implementation, review, and drafting. 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