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
- Create a user with a given name, like "bbs6100"
- 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.
"title": "first pull",
- 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:
"message": "An error occurred while processing the request. Check the server logs for more information.",
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.
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"
Ensure the username used in the query matches the casing used in the database.