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

Error responses are always HTML

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      Solr always returns an error response as HTML

      $ curl -i https://solr:8983/solr/admin/info/health                                                                              
      HTTP/2 401 
      content-type: text/html;charset=iso-8859-1
      
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
      <title>Error 401 Require authentication</title>
      </head>
      <body><h2>HTTP ERROR 401 Require authentication</h2>
      <table>
      <tr><th>URI:</th><td>/solr/admin/info/health</td></tr>
      <tr><th>STATUS:</th><td>401</td></tr>
      <tr><th>MESSAGE:</th><td>Require authentication</td></tr>
      <tr><th>SERVLET:</th><td>default</td></tr>
      </table></body>
      </html> 

      This is because Solr relies on Jetty's default ErrorHandler.

      It's not a big problem, since parsing the http code is normally enough, but this HTML tends to sneak into log messages and exceptions, and when you some times need to parse details to act on the root cause, parsing HTML is not a friendly format.

      Proposal is to override error handler and return a well defined JSON instead, perhpaps similar to Solr's existing error response format:

      {
        "responseHeader":{
          "status":401,
          "QTime":4},
        "error":{
          "metadata":[
            "error-class","my.class",
            "root-error-class","root.class"],
          "msg":"my message",
          "code":404}} 

      We could optionally look at Accept: header and/or wt= request param to determine whether to output something else than JSON.

      Attachments

        Activity

          People

            Unassigned Unassigned
            janhoy Jan Høydahl
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: