Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13205

StringIndexOutOfBoundsException in SolrQueryParserBase.getFieldQuery

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 9.0
    • 8.7, 9.0
    • search

    Description

      Requesting the following URL causes Solr to return an HTTP 500 error response:

      http://localhost:8983/solr/films/select?df=&explainOther=debug=all&debugQuery=on
      

      The error response seems to be caused by the following uncaught exception:

      java.lang.StringIndexOutOfBoundsException: String index out of range: 0
      at java.lang.String.charAt(String.java:658)
      at org.apache.solr.parser.SolrQueryParserBase.getFieldQuery(SolrQueryParserBase.java:1045)
      at org.apache.solr.parser.SolrQueryParserBase.handleBareTokenQuery(SolrQueryParserBase.java:801)
      at org.apache.solr.parser.QueryParser.Term(QueryParser.java:421)
      at org.apache.solr.parser.QueryParser.Clause(QueryParser.java:278)
      at org.apache.solr.parser.QueryParser.Query(QueryParser.java:162)
      at org.apache.solr.parser.QueryParser.TopLevelQuery(QueryParser.java:131)
      at org.apache.solr.parser.SolrQueryParserBase.parse(SolrQueryParserBase.java:255)
      at org.apache.solr.search.LuceneQParser.parse(LuceneQParser.java:49)
      at org.apache.solr.search.QParser.getQuery(QParser.java:173)
      at org.apache.solr.util.SolrPluginUtils.doSimpleQuery(SolrPluginUtils.java:479)
      at org.apache.solr.util.SolrPluginUtils.doStandardResultsDebug(SolrPluginUtils.java:390)
      at org.apache.solr.util.SolrPluginUtils.doStandardDebug(SolrPluginUtils.java:343)
      at org.apache.solr.handler.component.DebugComponent.process(DebugComponent.java:100)
      at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:306)
      at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)
      

      The “df” parameter means that we set the empty string as default field. Since we do not give a field in the query, the default field is substituted in getFieldQuery. We then check if the field starts with “_” by using charAt(0).

      A trivial fix would be to replace field.charAt(0) == ‘’ with field.startsWith(“”).

      To set up an environment to reproduce this bug, follow the description in the ‘Environment’ field.

      We automatically found this issue and ~70 more like this using Diffblue Microservices Testing. Find more information on this fuzz testing campaign.

      Attachments

        1. SOLR-13205.patch
          8 kB
          Pramod Kumar

        Issue Links

          Activity

            People

              gerlowskija Jason Gerlowski
              jkloos Johannes Kloos
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m