Skip to content

fix(indexing): one blank-input rule for every document format - #105

Open
adityamparikh wants to merge 2 commits into
apache:mainfrom
adityamparikh:fix/document-creator-null-validation
Open

fix(indexing): one blank-input rule for every document format#105
adityamparikh wants to merge 2 commits into
apache:mainfrom
adityamparikh:fix/document-creator-null-validation

Conversation

@adityamparikh

@adityamparikh adityamparikh commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Problem

Four formats, three different rules for blank input, in two different layers:

Format Where the check lives on main What it does
JSON JsonDocumentCreator.create isBlank()"JSON input cannot be empty"
CSV CsvDocumentCreator.create isBlank()"CSV input cannot be empty"
XML IndexingDocumentCreator (orchestrator), creator has none null || trim().isEmpty()"XML input cannot be null or empty"
Markdown orchestrator and creator orchestrator throws; creator silently returns 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

  • One 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.
  • No null checks: the creators are @NullMarked, so a null argument is a caller's contract violation, and the only place a runtime null can enter is the reflective @McpTool boundary (fix: validate collection name consistently across all MCP tool methods #108 guards collection there). A client omitting the xml or markdown argument now gets the same NPE-derived tool error JSON and CSV already produced on main, 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.
  • Interface and MarkdownDocumentCreator javadoc describe the one contract that now exists. Net: fewer lines than main, and no == null anywhere in the package.

Verification

  • DocumentCreatorBlankInputTest: 8 parameterized cases (4 formats × empty/whitespace), direct creator calls, no Spring. Written first; XML and Markdown fail on main, JSON and CSV pass as regression pins.
  • ./gradlew build on Java 25: 410 tests, 0 failures, 7 skipped (the OTLP suite, skipped on main until test(observability): re-enable OtlpExportIntegrationTest #198).

🤖 Generated with Claude Code

https://claude.ai/code/session_01CiUHyyXLTo9ATdgg8eRFZJ

@adityamparikh
adityamparikh force-pushed the fix/document-creator-null-validation branch from 51c5b8d to ac5e90d Compare May 2, 2026 17:04
@adityamparikh
adityamparikh force-pushed the fix/document-creator-null-validation branch from ac5e90d to a94d1f3 Compare August 18, 2026 21:25
@adityamparikh adityamparikh changed the title fix: add null/empty validation to JSON and CSV document creators fix(indexing): reject blank document input consistently across formats Aug 18, 2026
@adityamparikh
adityamparikh force-pushed the fix/document-creator-null-validation branch 2 times, most recently from a46d9b1 to 9fc28df Compare August 19, 2026 11:58
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>
@adityamparikh adityamparikh changed the title fix(indexing): reject blank document input consistently across formats fix(indexing): one blank-input rule for every document format Sep 11, 2026
@adityamparikh
adityamparikh force-pushed the fix/document-creator-null-validation branch from 9fc28df to 0851b26 Compare September 11, 2026 15:34
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant