fix(indexing): one blank-input rule for every document format - #105
adityamparikh wants to merge 2 commits into
Conversation
51c5b8d to
ac5e90d
Compare
ac5e90d to
a94d1f3
Compare
a46d9b1 to
9fc28df
Compare
The four creators disagreed on where and how blank input was rejected: JSON and CSV checked isBlank() in the creator, XML was checked only by the orchestrator (the creator itself failed with a parse error), and Markdown was checked in both places with different outcomes (orchestrator threw, creator returned an empty list). The messages differed too, and the interface javadoc promised three contracts none of them honoured. One SolrDocumentCreator.requireContent(content, format) helper now runs first in every create(); the orchestrator's two XML/Markdown checks are deleted. The helper checks blankness only. The creators are @NullMarked, so a null argument is a caller's contract violation rather than an input to validate; the null branches main still carried are removed along with the XML null test that pinned them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wh7SJkZhL1uuK7pYc3SLk8 Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
9fc28df to
0851b26
Compare
The create() javadoc still promised an empty list for blank input, which this change removes. The two parameterized tests differed only in the input literal, so they are one test over creators x blank inputs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
|
Closing as superseded. This PR consolidates four scattered blank-input checks into one #205 deletes half the call sites. It removes #202 and #207 rewrite the two survivors. #202 reworks The signature no longer covers the shape. #202 adds No behaviour is lost by closing. Blank input is still rejected on every Separately, its own rationale — "the creators are Thanks — the blank-input inconsistency it identified was real, and the repo-wide |
Problem
Four formats, three different rules for blank input, in two different layers:
mainJsonDocumentCreator.createisBlank()→"JSON input cannot be empty"CsvDocumentCreator.createisBlank()→"CSV input cannot be empty"IndexingDocumentCreator(orchestrator), creator has nonenull || trim().isEmpty()→"XML input cannot be null or empty"List.of()So
new XmlDocumentCreator().create("")fails with a parser error,new MarkdownDocumentCreator().create(" ")returns an empty list, and the interface javadoc promised three mutually exclusive contracts that no implementation honoured.Change
SolrDocumentCreator.requireContent(content, format)helper, blank-only, message"<FORMAT> input cannot be empty". Every creator calls it first, so the contract holds for direct callers and through the orchestrator alike; the orchestrator's XML/Markdown checks are deleted rather than moved.@NullMarked, so a null argument is a caller's contract violation, and the only place a runtime null can enter is the reflective@McpToolboundary (fix: validate collection name consistently across all MCP tool methods #108 guardscollectionthere). A client omitting thexmlormarkdownargument now gets the same NPE-derived tool error JSON and CSV already produced onmain, until MCP SDK 2.0 input validation (feat: upgrade to Spring Boot 4.1.1 and Spring AI 2.0.1 #23) rejects missing required arguments before dispatch.MarkdownDocumentCreatorjavadoc describe the one contract that now exists. No== nullanywhere in the package.Behavior changes to note:
MarkdownDocumentCreator.create("")returned an empty list and now throws, and the XML/Markdown messages drop the "or null" wording.Verification
DocumentCreatorBlankInputTestcovers 4 formats × empty/whitespace directly against each creator; the existing XML and Markdown expectations move to the new message../gradlew buildon Java 25: 410 tests, 0 failures.🤖 Generated with Claude Code