This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-mcp.git
The following commit(s) were added to refs/heads/main by this push:
new b41691c fix: unify document creator validation exceptions to
DocumentProcessingException (#116)
b41691c is described below
commit b41691c91dcefe28ddec0b358f23317de5520d5a
Author: Aditya Parikh <[email protected]>
AuthorDate: Fri May 1 16:58:28 2026 -0400
fix: unify document creator validation exceptions to
DocumentProcessingException (#116)
* test: update assertion in CollectionServiceIntegrationTest to check for
null errors
* test: update assertion in CollectionServiceIntegrationTest to check for
null timeouts
* fix(indexing): unify document creator validation exceptions to
DocumentProcessingException
Change XML validation in IndexingDocumentCreator from
IllegalArgumentException
to DocumentProcessingException for consistency with JSON and CSV document
creators. Callers can now catch a single exception type for all input
validation failures in the document creator layer.
Closes #20
---------
Signed-off-by: Aditya Parikh <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
---
.../indexing/documentcreator/IndexingDocumentCreator.java | 4 ++--
.../org/apache/solr/mcp/server/indexing/XmlIndexingTest.java | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git
a/src/main/java/org/apache/solr/mcp/server/indexing/documentcreator/IndexingDocumentCreator.java
b/src/main/java/org/apache/solr/mcp/server/indexing/documentcreator/IndexingDocumentCreator.java
index f20489a..d89af46 100644
---
a/src/main/java/org/apache/solr/mcp/server/indexing/documentcreator/IndexingDocumentCreator.java
+++
b/src/main/java/org/apache/solr/mcp/server/indexing/documentcreator/IndexingDocumentCreator.java
@@ -123,12 +123,12 @@ public class IndexingDocumentCreator {
// Input validation
if (xml == null || xml.trim().isEmpty()) {
- throw new IllegalArgumentException("XML input cannot be
null or empty");
+ throw new DocumentProcessingException("XML input cannot
be null or empty");
}
byte[] xmlBytes = xml.getBytes(StandardCharsets.UTF_8);
if (xmlBytes.length > MAX_XML_SIZE_BYTES) {
- throw new IllegalArgumentException(
+ throw new DocumentProcessingException(
"XML document too large: " +
xmlBytes.length + " bytes (max: " + MAX_XML_SIZE_BYTES + ")");
}
diff --git
a/src/test/java/org/apache/solr/mcp/server/indexing/XmlIndexingTest.java
b/src/test/java/org/apache/solr/mcp/server/indexing/XmlIndexingTest.java
index 77bdcb7..35129e8 100644
--- a/src/test/java/org/apache/solr/mcp/server/indexing/XmlIndexingTest.java
+++ b/src/test/java/org/apache/solr/mcp/server/indexing/XmlIndexingTest.java
@@ -21,6 +21,7 @@ import static
org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.List;
import org.apache.solr.common.SolrInputDocument;
+import
org.apache.solr.mcp.server.indexing.documentcreator.DocumentProcessingException;
import
org.apache.solr.mcp.server.indexing.documentcreator.IndexingDocumentCreator;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -343,7 +344,8 @@ class XmlIndexingTest {
// When/Then
assertThatThrownBy(() ->
indexingDocumentCreator.createSchemalessDocumentsFromXml(null))
-
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("XML input
cannot be null or empty");
+ .isInstanceOf(DocumentProcessingException.class)
+ .hasMessageContaining("XML input cannot be null
or empty");
}
@Test
@@ -352,7 +354,8 @@ class XmlIndexingTest {
// When/Then
assertThatThrownBy(() ->
indexingDocumentCreator.createSchemalessDocumentsFromXml(""))
-
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("XML input
cannot be null or empty");
+ .isInstanceOf(DocumentProcessingException.class)
+ .hasMessageContaining("XML input cannot be null
or empty");
}
@Test
@@ -361,7 +364,8 @@ class XmlIndexingTest {
// When/Then
assertThatThrownBy(() ->
indexingDocumentCreator.createSchemalessDocumentsFromXml(" \n\t "))
-
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("XML input
cannot be null or empty");
+ .isInstanceOf(DocumentProcessingException.class)
+ .hasMessageContaining("XML input cannot be null
or empty");
}
@Test
@@ -389,7 +393,7 @@ class XmlIndexingTest {
// When/Then
assertThatThrownBy(() ->
indexingDocumentCreator.createSchemalessDocumentsFromXml(largeXml.toString()))
-
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining("XML
document too large");
+
.isInstanceOf(DocumentProcessingException.class).hasMessageContaining("XML
document too large");
}
@Test