Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-69720

Using REST API to update a page fails with a misleading error message if no user-agent is provided

    XMLWordPrintable

Details

    Description

      Issue Summary

      Sending a request to the PUT /wiki/rest/api/content/{id} REST API endpoint in order to update a page fails returning below error message if no value is present/provided for the user-agent header:

      "Content body cannot be converted to new editor format" error when updating page content

      However:

      1. According to RFC 7231 the user agent is not mandatory (it says it should, not must):


        A user agent SHOULD send a User-Agent field in each request unless specifically configured not to do so.

      2. The error message returned is misleading and does not help understand what the problem is (it should mention: no user agent or something similar)

      Steps to Reproduce

      1. Update a page content sending a PUT request to the /wiki/rest/api/content/{id} endpoint without providing any user-agent header.

      Expected Results

      The page gets updated, or you get an error message saying that you must provide a value for the user-agent in order to be able to update content

      Actual Results

      You get status code 400 (bad request), that is correct, but the returned error message is totally misleading:

      "Content body cannot be converted to new editor format" error when updating page content

      The below exception is found in the logs:

      2020-03-27 13:37:06.521 ERROR com.atlassian.confluence.content.render.xhtml.DefaultRenderer Error rendering content for view: RuntimeException occurred while performing an XHTML storage transformation (null)   
      
      com.atlassian.confluence.content.render.xhtml.XhtmlException: RuntimeException occurred while performing an XHTML storage transformation (null)
      
      com.atlassian.confluence.content.render.xhtml.atlassiandocformat.StorageXhtmltoADFTransformer.transform(StorageXhtmltoADFTransformer.java:115)
      com.atlassian.confluence.content.render.xhtml.DefaultRenderer.renderWithoutMetrics(DefaultRenderer.java:188)
      com.atlassian.confluence.content.render.xhtml.DefaultRenderer.renderWithResult(DefaultRenderer.java:145)
      com.atlassian.confluence.content.render.xhtml.DefaultFormatConverter.convertToAtlasDocFormatWithResult(DefaultFormatConverter.java:174)
      com.atlassian.confluence.api.impl.service.content.ContentBodyConversionManagerImpl.computeConvertedValue(ContentBodyConversionManagerImpl.java:400)
      [.....]
      org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      java.lang.Thread.run(Thread.java:748)
      
       Caused by: java.lang.NullPointerException: 
      java.util.regex.Matcher.getTextLength(Matcher.java:1283)
      java.util.regex.Matcher.reset(Matcher.java:309)
      java.util.regex.Matcher.<init>(Matcher.java:229)
      java.util.regex.Pattern.matcher(Pattern.java:1093)
      com.atlassian.confluence.mobile.MobileUtils.getIosAppVersion(MobileUtils.java:33)
      [...]
      ... 367 more
      
      2020-03-27 13:37:06.521 WARN com.atlassian.confluence.api.impl.service.content.ContentBodyConversionManagerImpl Could not convert storage format to atlas_doc_format  format using ceo with id : -1    
      

      Workaround

      None, you must provide a value for the user agent.

      Attachments

        Activity

          People

            nagarwal@atlassian.com Niraj
            dbonotto Dario B
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: