Hello,
I'm using the v2 config API to create a schema and add some new components
to my collection.

I'm using solr 9.9.0 in cloud mode:

bin/solr start -f -c
bin/solr create -c test

Based on the documentation at
https://solr.apache.org/guide/solr/latest/query-guide/suggester.html#adding-the-suggest-search-component
and the examples at
https://solr.apache.org/guide/solr/latest/configuration-guide/config-api.html#how-to-map-solrconfig-xml-properties-to-json

I run the following API request to add the suggest component:

curl -X POST -H 'Content-type:application/json' -d '{
  "add-searchcomponent": {
    "name": "suggest",
    "class": "solr.SuggestComponent",
    "suggester": {
      "name": "my_suggester",
      "buildOnStartup": true
    }
  }
}' http://localhost:8983/api/collections/test/config

Note that this request is incorrect: I used a JSON boolean value for the
"buildOnStartup" parameter instead of a string containing the value "true".

When I run this request, the solr server gets in an invalid state and
returns this error, in an infinite loop as it tries to reload the collection

2025-11-04 10:29:20.199 ERROR (SolrConfigHandler-refreshconf) [c: s: r: x:
t:] o.a.s.h.SolrConfigHandler Unable to refresh conf  =>
org.apache.solr.common.SolrException: Unable to reload core
[test_shard1_replica_n1]
at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:2113)
org.apache.solr.common.SolrException: Unable to reload core
[test_shard1_replica_n1]
at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:2113) ~[?:?]
at
org.apache.solr.core.SolrCore.lambda$getConfListener$22(SolrCore.java:3458)
~[?:?]
at
org.apache.solr.handler.SolrConfigHandler$Command.lambda$handleGET$0(SolrConfigHandler.java:253)
~[?:?]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: org.apache.solr.common.SolrException: class java.lang.Boolean
cannot be cast to class java.lang.String (java.lang.Boolean and
java.lang.String are in module java.base of loader 'bootstrap')
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:1229) ~[?:?]
at org.apache.solr.core.SolrCore.cloneForReloadCore(SolrCore.java:808)
~[?:?]
at org.apache.solr.core.SolrCore.reload(SolrCore.java:777) ~[?:?]
at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:2073) ~[?:?]
... 3 more
Caused by: java.lang.ClassCastException: class java.lang.Boolean cannot be
cast to class java.lang.String (java.lang.Boolean and java.lang.String are
in module java.base of loader 'bootstrap')
at
org.apache.solr.handler.component.SuggestComponent.inform(SuggestComponent.java:146)
~[?:?]
at
org.apache.solr.core.SolrResourceLoader.inform(SolrResourceLoader.java:753)
~[?:?]
at org.apache.solr.core.SolrCore.<init>(SolrCore.java:1184) ~[?:?]
at org.apache.solr.core.SolrCore.cloneForReloadCore(SolrCore.java:808)
~[?:?]
at org.apache.solr.core.SolrCore.reload(SolrCore.java:777) ~[?:?]
at org.apache.solr.core.CoreContainer.reload(CoreContainer.java:2073) ~[?:?]
... 3 more

This makes sense given the code which tries to load the string value into a
boolean:
https://github.com/apache/solr/blob/19ec326349d1f31d6735f3b8c11b793503c77f43/solr/core/src/java/org/apache/solr/handler/component/SuggestComponent.java#L150

>From my perspective, it would be nice to be able to send "real" JSON
boolean values to this API, however I understand that it may be a major
change given that even the schema/config XML uses <str name="">true</str>
for boolean values.

At the very least it would be nice for the config API to return an HTTP 400
error if the json type of a parameter is unexpected or isn't one of the
expected values of "true" or "false". I see that there is already some
validation of these requests, for example if I send an add-searchcomponent
request with no "name" field then I get an HTTP 400 response
"{errorMessages=['name' is a required field]"

As an additional improvement it may be worth also adding a note about
boolean values at
https://solr.apache.org/guide/solr/latest/configuration-guide/config-api.html#how-to-map-solrconfig-xml-properties-to-json
(although I admit that I didn't read this page first and only came to it
after encountering this issue).

I have a jira account and can open this as an issue if required, or am
otherwise happy to answer any other questions.

Regards,
Alastair

Reply via email to