Skip to content

fix(config): accept text/plain content-type in JsonResponseParser#90

Merged
epugh merged 1 commit into
apache:mainfrom
dolphinium:fix/json-parser-text-plain
Jun 19, 2026
Merged

fix(config): accept text/plain content-type in JsonResponseParser#90
epugh merged 1 commit into
apache:mainfrom
dolphinium:fix/json-parser-text-plain

Conversation

@dolphinium

Copy link
Copy Markdown
Contributor

Split out from #89 at maintainer's request — this PR contains only the Content-Type tolerance fix.

Summary

Widens JsonResponseParser#getContentTypes() to advertise both application/json and text/plain, so SolrJ stops rejecting otherwise-valid JSON responses that are served with Content-Type: text/plain.

Motivation

Some Solr request handlers (notably /admin/ping and a number of standalone-mode paths) return JSON-encoded bodies with Content-Type: text/plain. SolrJ validates the response Content-Type against the set advertised by the configured ResponseParser and fails with:

Expected mime type in [application/json] but got text/plain

…even though the payload is a valid Solr JSON response. This surfaces to MCP clients through tools like check-health and search as errors, despite the underlying query succeeding.

Observed end-to-end against a real standalone Solr 9.x instance: check-health and search both return the error above pre-fix, and return clean results post-fix.

Changes

  • JsonResponseParser#getContentTypes: advertise application/json and text/plain.
  • No behavioural change for handlers that already return application/json.

Tests

  • JsonResponseParserContentTypesTest (new): pins the advertised Content-Type set.
  • ./gradlew build passes locally (Spotless + NullAway + full unit suite).

Test plan

  • ./gradlew spotlessCheck
  • ./gradlew build (unit tests)
  • Manual end-to-end against a standalone Solr 9.x — check-health and search now succeed on handlers that previously returned text/plain.

Notes

  • No new runtime dependencies.
  • Behaviour is strictly additive (accepting one more Content-Type).
  • Signed off under DCO; commit follows Conventional Commits per CONTRIBUTING.md.

Companion PR for the Basic Auth feature: #89

Co-authored-by: Claude noreply@anthropic.com

@adityamparikh

Copy link
Copy Markdown
Contributor

Hi! A new PR-validation CI workflow recently landed on main (#117). To get this PR's tests evaluated against the new pipeline, could you rebase your branch onto current main and push? That will trigger the new ci.yml (build / unit / integration). Thanks!

Some Solr request handlers (notably `/admin/ping` and certain
standalone-mode paths) return JSON-encoded bodies with a
`Content-Type: text/plain` header. SolrJ validates the response
Content-Type against the set advertised by the configured
`ResponseParser` and fails otherwise-valid responses with
"Expected mime type in [application/json] but got text/plain",
which surfaces through MCP tools such as `check-health` and
`search` as errors even though the payload is a correct Solr
JSON response.

Widen `JsonResponseParser#getContentTypes()` to advertise both
`application/json` and `text/plain` so these responses are parsed
normally. No behavioural change for handlers that return
`application/json`.

Adds `JsonResponseParserContentTypesTest` pinning the advertised
set.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Yunus Emre Korkmaz <yunus.emre.korkmaz@turboard.com>
@dolphinium dolphinium force-pushed the fix/json-parser-text-plain branch from 4329f76 to 354ed00 Compare June 2, 2026 15:47
@dolphinium

Copy link
Copy Markdown
Contributor Author

@adityamparikh Rebased both branches(#89 and #90) onto current main — conflicts resolved and ci.yml is now triggering (currently action_required). Could you approve the workflow runs? Thanks!

@adityamparikh

Copy link
Copy Markdown
Contributor

Looks good to me. @epugh can you please merge?

@epugh epugh merged commit 582490b into apache:main Jun 19, 2026
1 check passed
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.

3 participants