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

Cleanup WebEngine exceptions to have meaningful HTTP status code

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.3.2, 9.1-SNAPSHOT
    • Fix Version/s: 9.3
    • Component/s: WebEngine
    • Release Notes Description:
      Hide

      WebException (and most subclasses) has been deprecated, NuxeoException (and subclasses) are now the exceptions to be thrown, and those can be marshalled correctly by the new registered JsonNuxeoExceptionWriter.

      A new statusCode field has been added to NuxeoException to specify which HTTP code should be returned in case the exception is thrown, default to 500.

      ModuleResource#handleError(WebApplicationException e) has been changed to ModuleResource#handleError(Throwable t) to handle error at the WebEngine module level.

      Compatibility has been kept to still write WebException as JSON if they are thrown.

      Show
      WebException (and most subclasses) has been deprecated, NuxeoException (and subclasses) are now the exceptions to be thrown, and those can be marshalled correctly by the new registered JsonNuxeoExceptionWriter . A new statusCode field has been added to NuxeoException to specify which HTTP code should be returned in case the exception is thrown, default to 500. ModuleResource#handleError(WebApplicationException e) has been changed to ModuleResource#handleError(Throwable t) to handle error at the WebEngine module level. Compatibility has been kept to still write WebException as JSON if they are thrown.
    • Impact type:
      API change
    • Upgrade notes:
      Hide

      WebException (and most subclasses) has been deprecated, NuxeoException (and subclasses) are now the exceptions to be thrown, and those can be marshalled correctly by the new registered JsonNuxeoExceptionWriter.

      A new statusCode field has been added to NuxeoException to specify which HTTP code should be returned in case the exception is thrown, default to 500.

      ModuleResource#handleError(WebApplicationException e) has been changed to ModuleResource#handleError(Throwable t) to handle error at the WebEngine module level.

      Compatibility has been kept to still write WebException as JSON if they are thrown.

      Show
      WebException (and most subclasses) has been deprecated, NuxeoException (and subclasses) are now the exceptions to be thrown, and those can be marshalled correctly by the new registered JsonNuxeoExceptionWriter . A new statusCode field has been added to NuxeoException to specify which HTTP code should be returned in case the exception is thrown, default to 500. ModuleResource#handleError(WebApplicationException e) has been changed to ModuleResource#handleError(Throwable t) to handle error at the WebEngine module level. Compatibility has been kept to still write WebException as JSON if they are thrown.
    • Sprint:
      nxfit 9.3.8, nxfit 9.3.9
    • Story Points:
      8

      Description

      Go to https://nightly.nuxeo.com/nuxeo/site/api/v1/user/Administrator, you get the expected answer.
      If you go to https://nightly.nuxeo.com/nuxeo/site/api/v1/user/ you get a 500.
      Same thing if you shorten the URL https://nightly.nuxeo.com/nuxeo/site/api/v1/
      If the request URL is wrong, the server has no internal error it cannot handle. The response status code should be something better.

      This is for example annoying for production server monitoring, as these are false positive HTTP status 500 responses.

      Normally, when Jersey doesn't find an endpoint, it returns a 404. I know that we override the default Exception handling at the WebEngine level. I'm also convinced that we should return better return code. 500 is about an error that the server doesn't know how to handle. From what I remember, we have something that tries to automatically introspect the stacktrace to give for instance automatically a 404 when there is a NoSuchDocumentException it the stacktrace. I'm not a big fan of such mechanism, and we really should review it

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 0 minutes
                  0m
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week
                  1w