Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-30513

Return JSON with error message instead of HTML response for Generic HTTP 500 error

    XMLWordPrintable

    Details

    • Release Notes Summary:
      The error message is returned as JSON.
    • Backlog priority:
      850
    • Sprint:
      nxplatform #42
    • Story Points:
      3

      Description

      When Repository.PageProvider operation times out, a generic 500 internal server error is returned as HTML.

      Steps to reproduce:

      1. Run Repository.PageProvider operation using nxql_search pp and complex query.  Specify a short Nuxeo-Transaction-Timeout. E.g.
        curl --location --request POST 'http://localhost:8080/nuxeo/api/v1/automation/Repository.PageProvider' \
        --header 'X-NXproperties: *' \
        --header 'X-NXRepository: default' \
        --header 'content-type: application/json' \
        --header 'Nuxeo-Transaction-Timeout: 3' \
        --header 'Accept: application/json' \
        -u Administrator:Administrator \
        --data-raw '{
            "params": {
                "currentPageIndex": 0,
                "langauage": "NXQL",
                "maxResults": 200,
                "namedParameters": {},
                "pageSize": 1000,
                "providerName": "nxql_search",
                "queryParams": [
                    "query"
                ]
            }
        }'
        

      Expected Results: If error occurs, it is returned as json and an indication of the error is shown instead of generic "An error has occurred"

      Actual Results: When operation times out, the following HTML is returned

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
        <title>An error occurred.</title>
        <style type="text/css">
      <!--
      body { background: url("/nuxeo/img/error_pages/page_background.gif") repeat scroll 0 0 transparent;
        color: #999;
        font: normal 100%/1.5 "Lucida Grande", Arial, Verdana, sans-serif;
        margin: 0;
        text-align: center }
      
      .container {  margin: 2em auto;
        text-align: center;
        width: 70% }
      
      h1 { color: #000;
        font-size: 150%;
        margin: 3.5em 0 .5em 0 }
      
      h2 { color: #b20000;
        font-size: 110%;
        margin: 1em }
      
      h1, h2 { font-weight: bold }
      
      p { max-width: 600px; margin: .4em auto }
      
      a.block { background: url("/nuxeo/img/error_pages/refresh.png") no-repeat scroll center 10px #fff;
        border: 1px solid #ddd;
        border-radius: 5px;
        color: #00729c;
        display: inline-block;
        font-weight: bold;
        margin: .4em;
        padding: 3em .5em .8em;
        text-align: center;
        text-decoration: none;
        vertical-align: top;
        width: 7em }
      a.block:hover { background-color: #e9f1f4; border-color: #e9f1f4; color: #000 }
      a.block.back { background-image: url("/nuxeo/img/error_pages/back.png") }
      a.block.stack { background-image: url("/nuxeo/img/error_pages/show.png") }
      a.block.dump { background-image: url("/nuxeo/img/error_pages/view.png") }
      
      .block img { display: block;
          margin: 0 auto }
      
      .links { margin: 2em 0 0 0 }
      .links span { display: inline-block;
        font-size: 85% }
      
      .errorDetail { background-color:#fff;
        border: 1px solid #ccc;
        border-radius: 5px;
        height: 40%;
        margin: 1em auto;
        overflow: auto;
        padding: 0.5em;
        text-align: left;
        width: 100% }
      -->
        </style>
        <script language="javascript" type="text/javascript">
          function toggleError(id) {
            var style = document.getElementById(id).style;
            if ("block" == style.display) {
              style.display = "none";
            } else {
              style.display = "block";
            }
          }
        </script>
      </head>
      <body>
      
        <div class="container">
          <h1>An error occurred.</h1>
      
          
            <p>An unexpected error occurred. Click on the following links to get more information or go back to the application.</p>
            <div class="links">
      
              <a class="block back" href="/nuxeo/">
                <span>Back to Home Page</span>
              </a>
              <a class="block change" href="/nuxeo/logout">
                <span>Log Out</span>
              </a>
            </div>
        </div>
      </body>
      </html>
      

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: