Uploaded image for project: 'Bitbucket Data Center'
  1. Bitbucket Data Center
  2. BSERV-12251

Filtering pull requests by username through REST API fails if database/query username casing doesn't match

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Low
    • 6.10.3, 7.0.2
    • 6.10.0, 6.10.1
    • Pull Requests
    • None

    Description

      Issue Summary

      When searching pull requests using the REST API with a username filter, if a user's case-insensitive-but-case-preserving username in the database doesn't match the casing used in the query (e.g. username "bbs6100" in the database, and "BbS6100" used in the query), the query fails with a NullPointerException.

      Steps to Reproduce

      1. Create a user with a given name, like "bbs6100"
      2. Search for pull requests using username.1=bbs6100 (matching the database's casing):
        curl -u <admin_user:password> -X GET -H "X-PrettyPrint:1" -H "Content-Type: application/json" <Bitbucket_base_url>/rest/api/1.0/projects/PR2/repos/myrepotest/pull-requests?username.1=bbs6100
        

        Retrieves pull requests successfully.

        {
          "size": 1,
          "limit": 25,
          "isLastPage": true,
          "values": [
            {
              "id": 1,
              "version": 1,
              "title": "first pull",
              "description": "pr",
        
      3. Search for pull requests using username.1=BbS6100 (case mismatch):
        curl -u <admin_user:password> -X GET -H "X-PrettyPrint:1" -H "Content-Type: application/json" <Bitbucket_base_url>/rest/api/1.0/projects/PR2/repos/myrepotest/pull-requests?username.1=Bbs6100
        

        The request fails like this:

        {
          "errors": [
            {
              "context": null,
              "message": "An error occurred while processing the request. Check the server logs for more information.",
              "exceptionName": null
            }
          ]
        }
        

      Expected Results

      The REST API rest/api/1.0/projects/PR2/repos/myrepotest/pull-requests?username.1=Bbs6100 should work in a case-insensitive manner and both queries should return the same results.

      Actual Results

      The request fails with a NullPointerException, which is logged similar to the following in atlassian-bitbucket.log:

      20-03-20 12:38:50,273 ERROR [http-nio-26100-exec-8] bbs6100 @Z10WHZx758x36x0 0:0:0:0:0:0:0:1 "GET /rest/api/1.0/projects/PR2/repos/myrepotest/pull-requests HTTP/1.1" c.a.s.i.r.e.DefaultUnhandledExceptionMapperHelper Unhandled exception while processing REST request: "GET /rest/api/1.0/projects/PR2/repos/myrepotest/pull-requests HTTP/1.1"
      java.lang.NullPointerException: user
      

      Workaround

      Ensure the username used in the query matches the casing used in the database.

      Attachments

        Activity

          People

            bturner Bryan Turner (Inactive)
            tpothuraju@atlassian.com Tejaswini P
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: