Skip to content

[Ready] SOLR-7498: A stream with an unknown size gets no stream_size value. A known size is still recorded - #5137

Draft
nick-boss-tech wants to merge 6 commits into
apache:mainfrom
nick-boss-tech:solr-7498-submit
Draft

nick-boss-tech wants to merge 6 commits into
apache:mainfrom
nick-boss-tech:solr-7498-submit

Conversation

@nick-boss-tech

@nick-boss-tech nick-boss-tech commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

Ready for review, but held as a draft due to the project's open-PR cap; I'll mark it open on request.

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 at base). The loader passes that null on as the request's stream size (ExtractingDocumentLoader.java L139 at base). The metadata builder then called String.valueOf on it, so the metadata held the text null (ExtractionBackend.java L55 at base).

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). 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 (type: fixed)

AI assistance

AI agents assisted with research, implementation, review, and drafting. Nick Shanin directed the work and takes responsibility for this contribution.

@nick-boss-tech
nick-boss-tech marked this pull request as ready for review October 16, 2026 06:47
@nick-boss-tech nick-boss-tech changed the title SOLR-7498: A stream with an unknown size gets no stream_size value. A known size is still recorded [Ready] SOLR-7498: A stream with an unknown size gets no stream_size value. A known size is still recorded Oct 28, 2026
@nick-boss-tech
nick-boss-tech marked this pull request as draft October 28, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant