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

Raising an exception while using REST shows the whole stack trace

    XMLWordPrintable

    Details

    • Release Notes Summary:
      Stack trace information is excluded from the REST API response body by default when there is an exception.
    • Tags:
    • Backlog priority:
      500
    • Upgrade notes:
      Hide

      Nuxeo version >= 10.1

      By default, the exception stack trace is not written in the returned response when using the REST API. If you want to have it back, you need to set the nuxeo.conf parameter org.nuxeo.rest.stack.enable to true.
      See https://doc.nuxeo.com/nxdoc/error-handling/ for more information.

      Nuxeo version < 10.1

      The exception stack trace is still written if the media type is application/json+nxentity but it can be disabled for security reason with the nuxeo.rest.write.exception.stack.trace configuration parameter, which is set to true by default.

      To disable it:

      <extension target="org.nuxeo.runtime.ConfigurationService" point="configuration">
        <property name="nuxeo.rest.write.exception.stack.trace">false</property>
      </extension>
      
      Show
      Nuxeo version >= 10.1 By default, the exception stack trace is not written in the returned response when using the REST API. If you want to have it back, you need to set the nuxeo.conf parameter org.nuxeo.rest.stack.enable to true . See https://doc.nuxeo.com/nxdoc/error-handling/ for more information. Nuxeo version < 10.1 The exception stack trace is still written if the media type is application/json+nxentity but it can be disabled for security reason with the nuxeo.rest.write.exception.stack.trace configuration parameter, which is set to true by default. To disable it: <extension target= "org.nuxeo.runtime.ConfigurationService" point= "configuration" > <property name= "nuxeo. rest .write.exception.stack.trace" > false </property> </extension>
    • Sprint:
      nxfit 10.1.5
    • Story Points:
      3

      Description

      1. Install Nuxeo 8.10
      2. Install ffischer-8-rest-test.zip package
      3. copy jar file event-test-project-core-1.0-SNAPSHOT.jar
      4. Start server
      5. create a document of type myDoc
      6. retrieve its id by exporting it as XML for example
      7. try to modify it through rest:
        curl -u Administrator:Administrator -H "Content-Type: application/json" -X PUT http://localhost:8080/nuxeo/api/v1/id/beed4b9d-611e-4e0d-b46a-ac3fe5afc53a -d '{
                "entity-type": "document",
                "repository": "default",
                "uid": "4fe2843b-298c-42dd-bc32-4180ee521761",
                "properties": {
                    "dc:title": "The new title",
                    "dc:description": "Attempt to update through REST API"
                }
            }'
      8. this returns the full stack of the exception
      9. setting the parameter org.nuxeo.rest.stack.enable to false does not change the behavior
      10. the same could be observed in a unit test by trying the JsonFactoryManager.toggleStackDisplay method

      After checking with dev in a debug session, this is due to the following code in JsonWebengineWriter:

      if (jsonFactoryManager.isStackDisplay()
                      || MediaType.valueOf(MediaType.APPLICATION_JSON + "+nxentity").equals(mediaType)) {
      

      When raising the exception, at some point the type is changed from application/json to application/nx+entity thus falsing the above condition.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 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 day
                  1d