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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-7390
   
   ## What happens today
   
   **An unknown document transformer in `fl` is silently ignored, and the 
request succeeds.**
   
   For example, `fl=id,name,[asdgasdgasgdasg]` returns no error. The bracket 
term adds no transformer and matches no field, so nothing shows that it was 
ignored. The ticket reports the same result. On the base code, the branch for a 
bracket name with no registered factory is empty. Only a commented-out throw 
remains ([base 
lines](https://github.com/nick-boss-tech/solr/blob/0cc328310f8f4162572ea5bd5256cea29543e261/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L386-L389)).
   
   ## What this change does
   
   **An unregistered bracket transformer in `fl` now fails with 400 Bad 
Request.**
   
   The empty branch now throws `SolrException` with `BAD_REQUEST` and the 
message `Unknown DocTransformer: <name>` ([lines 386 to 389 at 
head](https://github.com/nick-boss-tech/solr/blob/7463dd006a7825db46f00b8a4790650c5bb51e61/solr/core/src/java/org/apache/solr/search/SolrReturnFields.java#L386-L389)).
 The plain form and the aliased form, such as `alias:[name foo=bar]`, both 
reach this check.
   
   Behavior changes, stated openly:
   
   - The check applies to any name the core has not registered, not only to 
typos. For example, `[elevated]` is registered only when the elevator component 
is configured ([QueryElevationComponent at the 
merge-base](https://github.com/nick-boss-tech/solr/blob/0cc328310f8f4162572ea5bd5256cea29543e261/solr/core/src/java/org/apache/solr/handler/component/QueryElevationComponent.java#L232-L239)).
 On a core without that component, `fl=id,[elevated]` now returns 400.
   - The existing test case that expected `[xxxxx]` to be ignored now expects 
the 400 ([test lines 293 to 300 at 
head](https://github.com/nick-boss-tech/solr/blob/7463dd006a7825db46f00b8a4790650c5bb51e61/solr/core/src/test/org/apache/solr/search/ReturnFieldsTest.java#L293-L300)).
   
   ## Proof
   
   **The updated test fails on the base code and passes with this change.**
   
   With the new test file on the base source, `testTransformers` fails with 
"Expected exception SolrException but no exception was thrown". The class runs 
15 tests with that one failure. With this change, at head `7463dd006a7`, 
`ReturnFieldsTest` passes 15 of 15. Neighbor classes on the same source pass as 
well: `TestPseudoReturnFields` 31 of 31, `TestExplainDocTransformer` 1 of 1, 
and `TestCustomDocTransformer` 1 of 1. The run used an earlier commit on this 
branch with identical source and test files. Verified 2026-10-05 at this head.
   
   ## A choice to check
   
   **Unknown transformers now fail, while unknown field names in `fl` are still 
ignored.**
   
   The other route is to keep ignoring an unknown transformer, the way an 
unknown field name is ignored today. That keeps old requests working, including 
requests that name a transformer the core does not have. The cost of this route 
is that such requests now fail. The ticket's second comment raises the same 
question. Was failing with 400 the right call?
   
   ## Limits
   
   **Four test classes were run, and the error message wording is not tested.**
   
   - Other classes that send unregistered names were not run.
   - A bracket term with no type name, such as `fl=[foo=bar]`, reaches the same 
throw with the name `null`, so the message reads "Unknown DocTransformer: null".
   - The default transformers (explain, value, docid, shard, child, subquery, 
json, xml, geo, core) are not changed.
   
   Changelog: 
[changelog/unreleased/SOLR-7390-unknown-doc-transformer.yml](https://github.com/nick-boss-tech/solr/blob/7463dd006a7825db46f00b8a4790650c5bb51e61/changelog/unreleased/SOLR-7390-unknown-doc-transformer.yml#L1-L8)
   
   ### 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