Repository navigation
fix: keep Solr failure text out of MCP resource responses; drop JsonUtils - #275
Merged
Merged
Conversation
adityamparikh
force-pushed
the
refactor/inline-json-utils
branch
from
October 21, 2026 15:14
9c7b379 to
67d6c9b
Compare
…ectly JsonUtils.toJson existed to wrap Jackson 2's checked JsonProcessingException. Jackson 3's JacksonException is unchecked, so the helper now only swallows serialization failures into an error JSON body, and every caller already holds an injected ObjectMapper. Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com> Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
getSchemaResource returned the exception message in its error JSON, and
getCollectionsResource let SolrServerException, IOException and
JacksonException escape. Spring AI's resource callback reports the root
cause's message to the client, and Solr and SolrJ failure text carries the
internal Solr URL ("Error from server at <url>: ...").
Both resources now log the full failure and throw an IllegalStateException
with a fixed message, a next-step hint and no cause, following
SearchService. The schema resource no longer returns {"error": ...} as a
successful read, which a client cannot tell apart from a schema.
McpClientIntegrationTestBase reads solr://no_such_collection_xyz/schema
over HTTP and stdio and asserts the MCP error names the failure without
"Error from server" or a Solr URL.
Signed-off-by: Aditya Parikh <aditya.m.parikh@gmail.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
adityamparikh
force-pushed
the
refactor/inline-json-utils
branch
from
October 26, 2026 19:24
67d6c9b to
e66a469
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Two related changes to the MCP resource endpoints
solr://collectionsandsolr://{collection}/schema.Keep Solr failure text out of resource responses
Solr and SolrJ failure text can carry internal host names, URLs and paths (for example
Server refused connection at: http://solr-internal:8983/solr). Both resources were passing that text to the client:SchemaService.getSchemaResourcereturnede.getMessage()in its error JSON.CollectionService.getCollectionsResourceletSolrServerException/IOExceptionescape, and MCP reports exceptions to the client by their root-cause message.Both now follow the pattern
SearchServicealready uses. They log the full failure on the server and throw anIllegalStateExceptionwith a fixed message, a next-step hint and no cause (SCHEMA_RESOURCE_ERROR,COLLECTIONS_RESOURCE_ERROR), so Spring AI's resource callback has no Solr failure to report. The client gets a proper MCP error. The schema resource no longer returns{"error": ...}as a successful read, which a client could not tell apart from a schema.getCollectionsResourceno longer declares checked exceptions.Tests:
McpClientIntegrationTestBase(HTTP and stdio) readssolr://no_such_collection_xyz/schemaand asserts that the MCP error names the failure, withoutError from serveror anhttp(s)://URL. Before this change the read succeeded with{"error": "Error from server at http://…"}.SchemaServiceTestandCollectionServiceTestfeed a Solr failure containing an internal URL and assert that the exception carries only the fixed message and no cause. A success-path test is also added for the collections resource, which had no tests before.Drop
JsonUtilsJsonUtils.toJson(objectMapper, obj)existed to wrap Jackson 2's checkedJsonProcessingException. Since the move to Jackson 3,JacksonExceptionis unchecked. Both callers already have anObjectMapperinjected, so the three call sites now callobjectMapper.writeValueAsString(...)directly. A serialization failure goes through the same safe error handling as above../gradlew buildpasses: 470 tests, 0 failures, 0 skipped. Merges cleanly with #276.🤖 Generated with Claude Code