Skip to content

SOLR-18191: draft - #4329

Draft
renatoh wants to merge 6 commits into
apache:mainfrom
renatoh:SOLR-18191-disable-lenient-json-parsing-in-api
Draft

SOLR-18191: draft#4329
renatoh wants to merge 6 commits into
apache:mainfrom
renatoh:SOLR-18191-disable-lenient-json-parsing-in-api

Conversation

@renatoh

@renatoh renatoh commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@renatoh

renatoh commented Apr 24, 2026

Copy link
Copy Markdown
Contributor Author

@malliaridis
it is still a draft, but something like this could work

I believe my changes to org.apache.solr.jersey.MessageBodyReaders.CachingJsonMessageBodyReader is an existing bug, don't see why we should not use SolrJacksonMapper.getObjectMapper()

@renatoh
renatoh marked this pull request as draft April 24, 2026 15:21

@malliaridis malliaridis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping for a simple flag that can be set in the object mapper or somewhere else that turns off the lenient behavior, but apparently jackson does not have such flag. Instead, you have to configure each feature / flag individually and set them all to the strict behavior (whether this is true or false) manually. And Jackson has a lot of flags.

.registerModule(customTypeModule);

mapper
.coercionConfigFor(LogicalType.Textual)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This only covers lenient cases for where text / string is expected. For cases where a number is expected and a text is provided, this will not catch a bad type.
  • This approach only covers cases that are listed. For example, I am allowed to provide true instead of a string and it will not fail.
  • When running into this coercion violation, the message could be optimized by customizing it (if possible). Right now it says:
    "msg": "Cannot coerce Integer value (123) to `java.lang.String` value (but could if coercion was enabled using `CoercionConfig`)"
    

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @malliaridis
I think we have covered all the case you mention, have a look at the tests.
I managed to change the error message, you pass in "name": 123 you get now:
"Invalid value for field 'name': expected String.

if (v1ParamMap.get("newCollection") instanceof String newCollectionStr) {
v1ParamMap.put("newCollection", Boolean.valueOf(newCollectionStr));
}

@renatoh renatoh Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malliaridis Your tests are passing now, but I had to do these changes, else it blows up already on the test setup, with this exception:
org.apache.solr.client.solrj.RemoteSolrException: Error from server at http://127.0.0.1:53370/solr: org.apache.solr.common.SolrException: Underlying core creation failed while creating collection: collection1 at __randomizedtesting.SeedInfo.seed([99D40937BA20F6D9]:0) at app//org.apache.solr.client.solrj.apache.HttpSolrClient.executeMethod(HttpSolrClient.java:685) at app//org.apache.solr.client.solrj.apache.HttpSolrClient.request(HttpSolrClient.java:255) at app//org.apache.solr.client.solrj.apache.HttpSolrClient.request(HttpSolrClient.java:234) at app//org.apache.solr.client.solrj.impl.LBSolrClient.doRequest(LBSolrClient.java:629) at app//org.apache.solr.client.solrj.impl.LBSolrClient.doRequest(LBSolrClient.java:613) at app//org.apache.solr.client.solrj.impl.LBSolrClient.doRequest(LBSolrClient.java:638) at app//org.apache.solr.client.solrj.impl.LBSolrClient.request(LBSolrClient.java:582) at app//org.apache.solr.client.solrj.impl.CloudSolrClient.sendRequest(CloudSolrClient.java:1596) at app//org.apache.solr.client.solrj.impl.CloudSolrClient.requestWithRetryOnStaleState(CloudSolrClient.java:1231) at app//org.apache.solr.client.solrj.impl.CloudSolrClient.request(CloudSolrClient.java:1153) at app//org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:302) at app//org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:348) at app//org.apache.solr.handler.V2ApiIntegrationTest.createCluster(V2ApiIntegrationTest.java:62)

What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malliaridis Any other cases we need to consider?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants