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

   🤖 *AI text below* 🤖 *(posted on behalf of Nick Shanin)*
   
   https://issues.apache.org/jira/browse/SOLR-7498
   
   ## What happens today
   
   **The extracting handler can store the text "null" as `stream_size`, and the 
numeric field then rejects the document.**
   
   When the size of an uploaded stream is not known, `ContentStream.getSize()` 
returns null ([ContentStream.java 
L39](https://github.com/nick-boss-tech/solr/blob/14c7aac0d151402b00259e2fb9bf5eed7049ec5d/solr/solrj/src/java/org/apache/solr/common/util/ContentStream.java#L39)).
 The loader passes that null on as the request's stream size 
([ExtractingDocumentLoader.java L139 at 
base](https://github.com/nick-boss-tech/solr/blob/14c7aac0d151402b00259e2fb9bf5eed7049ec5d/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractingDocumentLoader.java#L139)).
 The metadata builder then called `String.valueOf` on it, so the metadata held 
the text `null` ([ExtractionBackend.java L55 at 
base](https://github.com/nick-boss-tech/solr/blob/14c7aac0d151402b00259e2fb9bf5eed7049ec5d/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionBackend.java#L55)).
   
   The ticket reports `Error adding field 'stream_size'='null' msg=For input 
string: "null"` from a SolrJ `ContentStreamUpdateRequest` upload. The reporter 
says Solr's post tool works, because it sends a numeric size.
   
   ## What this change does
   
   **A stream with an unknown size gets no `stream_size` value. A known size is 
still recorded.**
   
   `buildMetadataFromRequest` adds `stream_size` only when the request has a 
size ([ExtractionBackend.java 
L55-L58](https://github.com/nick-boss-tech/solr/blob/2050d8e447a733966d5f6e4742a1a8ea931a2b00/solr/modules/extraction/src/java/org/apache/solr/handler/extraction/ExtractionBackend.java#L55-L58)).
 Any non-null size is kept, zero included.
   
   Behavior change: a document from a stream of unknown size no longer carries 
`stream_size`. It used to carry the text `null`.
   
   ## Proof
   
   **One new test fails on the base code and passes with the change. The other 
two classes in the module pass and are not changed.**
   
   - `ExtractionBackendMetadataTest` 2 of 2 at 
`2050d8e447a733966d5f6e4742a1a8ea931a2b00`, verified 2026-10-05. On the base 
code, `testUnknownStreamSizeIsNotAdded` fails because the metadata holds the 
text `null`. `testKnownStreamSizeIsAdded` passes on both.
   - `XmlSanitizingReaderTest` 2 of 2 and 
`ExtractingRequestHandlerPermissionTest` 6 of 6 at the same head. This patch 
does not change them.
   
   ## Limits
   
   **The test checks the metadata builder. It does not send an upload through 
the handler.**
   
   - The test builds the metadata directly. It does not send a SolrJ upload to 
`/update/extract`. The cause of the unknown size in the reporter's upload was 
not traced. An end-to-end test is not in this PR. A PR for it can be opened on 
request.
   - Documents already indexed with the text `null` keep it. Reindexing them is 
the fix for those documents.
   
   Changelog: 
[`changelog/unreleased/SOLR-7498-extract-null-stream-size.yml`](https://github.com/nick-boss-tech/solr/blob/2050d8e447a733966d5f6e4742a1a8ea931a2b00/changelog/unreleased/SOLR-7498-extract-null-stream-size.yml)
 (type: fixed)
   
   ### 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