You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Jan Høydahl (Jira)" <ji...@apache.org> on 2020/05/29 08:09:00 UTC

[jira] [Created] (SOLR-14522) Error responses are always HTML

Jan Høydahl created SOLR-14522:
----------------------------------

             Summary: Error responses are always HTML
                 Key: SOLR-14522
                 URL: https://issues.apache.org/jira/browse/SOLR-14522
             Project: Solr
          Issue Type: Improvement
      Security Level: Public (Default Security Level. Issues are Public)
            Reporter: Jan Høydahl


Solr always returns an error response as HTML
{code:java}
$ 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> {code}
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:
{code:java}
{
  "responseHeader":{
    "status":401,
    "QTime":4},
  "error":{
    "metadata":[
      "error-class","my.class",
      "root-error-class","root.class"],
    "msg":"my message",
    "code":404}} {code}
We could optionally look at {{Accept:}} header and/or {{wt=}} request param to determine whether to output something else than JSON.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org