nick-boss-tech opened a new pull request, #5074: URL: https://github.com/apache/solr/pull/5074
🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)* https://issues.apache.org/jira/browse/SOLR-5887 ## What happens today **Bad-document errors name the field but not the core.** An update with a document that has an unknown field returns a 400 error. The text is built in `DocumentBuilder` from the document id and the field name ([DocumentBuilder.java](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/java/org/apache/solr/update/DocumentBuilder.java#L301-L305)). ## What this change does **The error text gets a `core <name>:` prefix.** Every path that builds a Lucene document from an add command now goes through a wrapper, `toLuceneDocument` ([AddUpdateCommand.java](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java#L235-L248)). The wrapper covers in-place updates, single documents, and nested documents ([line 103](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java#L103), [line 212](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java#L212), [line 231](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java#L231)). For a 400 error from `DocumentBuilder`, with a core on the request, the wrapper rethrows the error with `core <name>: ` a dded before the original text. The error code stays 400. Other errors, and requests with no core, keep their current text. Behavior change: the text no longer starts with `ERROR:`. Anything that matches the start of the text will see a change. The tolerant update processor records these messages in its response, so clients see the new text there too. ## Proof **`DocumentBuilderTest.testAddUpdateCommandErrorNamesCore` checks that the error names the core.** The test ([DocumentBuilderTest.java](https://github.com/nick-boss-tech/solr/blob/c4c57ef7bcbde765807bf02f9e3a6db605868b7e/solr/core/src/test/org/apache/solr/update/DocumentBuilderTest.java#L78-L92)) sends a document with an unknown field through `AddUpdateCommand.makeLuceneDocs()`. It checks the 400 status, the core name, and the field name. On base production, `DocumentBuilderTest` runs 17 tests with exactly one failure: `testAddUpdateCommandErrorNamesCore`. The base message has no core name, which is what this test checks. With this change, `DocumentBuilderTest` passes 17 of 17 (verified 2026-10-07 at this head). ## Limits **Existing tests that match these messages were checked by reading, not run.** These are `TolerantUpdateProcessorTest`, `DocumentBuilderTest`, `TestManagedSchema`, and `TestSolrJErrorHandling`. They match the message text with `contains`, so the new prefix should not break them. None of them was run for this change. Changelog: `changelog/unreleased/SOLR-5887-doc-error-core-name.yml` ### 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]
