Uploaded image for project: 'Bitbucket Server'
  1. Bitbucket Server
  2. BSERV-12715

Multi-byte characters in a pull request description can result in branch list not loading

    XMLWordPrintable

    Details

      Description

      Issue Summary

      If a repository's branch is associated with a single pull request (regardless of the PR's status), and that pull request has a multi-byte character in its description (such as an emoji) - it's possible that there will be an error when retrieving the pull-request metadata for the branch.

      This then causes any view of the 'branches' section of a repository that has this branch to then throw an error and not load.

      Steps to Reproduce

      1. Add a commit to a branch, then create a pull request for this branch to be merged into a different branch
      2. In the pull request description, include a variety of content, including multi-byte characters such as emojis (ex: 🤔)
      3. Ensure the branch only has a single PR associated with it
        • The bug cannot be reproduced if this branch has more than one PR logged against it
        • Depending on the combination of characters used in the description, the issue may be inconsistent to reproduce, as the issue triggers when the library processing the description ends a 2k byte chunk on one of these multi-byte characters.

      Expected Results

      The branches page loads without issue, regardless of the content in any related pull request description.

      Actual Results

      The branch page fails to load when the branch associated with that PR is contained within the results:

      The below exception is thrown in the atlassian-bitbucket.log file:

      2021-01-05 19:02:25,603 ERROR [http-nio-7990-exec-712] @1XG8HBUx1142x51545299x0 1lpqaaj 10.14.196.4,127.0.0.1 "GET /mvc/error500 HTTP/1.0" c.a.s.i.web.ErrorPageController There was an unhandled exception loading [/rest/api/latest/projects/test/repos/test_repo/branches]
      org.codehaus.jackson.JsonGenerationException: Split surrogate on writeRaw() input (last character)
      	at org.codehaus.jackson.impl.JsonGeneratorBase._reportError(JsonGeneratorBase.java:480)
      	at org.codehaus.jackson.impl.Utf8Generator._outputRawMultiByteChar(Utf8Generator.java:1647)
      	at org.codehaus.jackson.impl.Utf8Generator._writeSegmentedRaw(Utf8Generator.java:815)
      	at org.codehaus.jackson.impl.Utf8Generator.writeRaw(Utf8Generator.java:729)
      	at org.codehaus.jackson.impl.Utf8Generator.writeRaw(Utf8Generator.java:697)
      	at org.codehaus.jackson.impl.JsonGeneratorBase.writeRawValue(JsonGeneratorBase.java:254)
      	at com.atlassian.bitbucket.rest.util.RestJsonable$RestJsonSerializer.serialize(RestJsonable.java:47)
      	at com.atlassian.bitbucket.rest.util.RestJsonable$RestJsonSerializer.serialize(RestJsonable.java:39)
      

      Workaround

      Either:

      • Find the offending PR, and edit the description to remove any multi-byte characters. Then, save your change to the PR and reload the branches page.

      OR

      • Create a second PR for the affected branch, as the issue will only occur when a branch as a single PR associated with it. This second PR can then be either merged or declined, but cannot be deleted.

      Notes

      The root cause is related to the following bug in the third-party jackson library:

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              eslaughter@atlassian.com Evan Slaughter
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Backbone Issue Sync