Bitbucket Data Center: "More than one row with the given identifier" error

Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Learn how to troubleshoot and fix Bitbucket permission errors when multiple database rows share the same identifier, causing 500 Internal Server Errors while visitng repository configuration or permissions page in Bitbucket.

Diagnosis

  • When accessing Repository settings, the page fails to load with a 500 Internal Server Error and the message: "A database error has occurred."

  • Bitbucket Application logs atlassian-bitbucket.log will show the error log below

ERROR [http-nio-7990-exec-3] ... o.h.e.i.DefaultLoadEventListener HHH000327: Error performing load command org.hibernate.HibernateException: More than one row with the given identifier was found: <ID>, for class: com.atlassian.stash.internal.user.InternalScopedPermission

Cause

Bitbucket uses a unified view, InternalScopedPermission, to manage permissions across the Global, Project, and Repository levels.

This error occurs when the same numeric ID exists in multiple permission tables (e.g., sta_global_permission and sta_project_permission). When Hibernate attempts to load a permission by that ID, it finds multiple rows rather than a single row, resulting in an application failure.

Solution

Step 1: Identify the Conflicting Records

Run the following SQL query to find which tables contain the duplicate ID (replace <ID> with the identifier from your logs):

SELECT internalsc0_.id AS id1_94_0_, internalsc0_.group_name AS group_na2_94_0_, internalsc0_.perm_id AS perm_id3_94_0_, internalsc0_.user_id AS user_id4_94_0_, internalsc0_.project_id AS project_1_118_0_, internalsc0_.repo_id AS repo_id1_125_0_, internalsc0_.clazz_ AS clazz_0_ FROM ( -- Global Permissions (Class 1) SELECT id, group_name, perm_id, user_id, NULL::int4 AS project_id, NULL::int4 AS repo_id, 1 AS clazz_ FROM sta_global_permission UNION ALL -- Project Permissions (Class 2) SELECT id, group_name, perm_id, user_id, project_id, NULL::int4 AS repo_id, 2 AS clazz_ FROM sta_project_permission UNION ALL -- Repository Permissions (Class 3) SELECT id, group_name, perm_id, user_id, NULL::int4 AS project_id, repo_id, 3 AS clazz_ FROM sta_repo_permission ) internalsc0_ WHERE internalsc0_.id = <ID>;

Step 2: Map IDs to Human-Readable Names

Identify the user and project involved so you can restore access later.

Find User Name:

SELECT name, display_name FROM sta_user WHERE id = <USER_ID_FROM_QUERY>;

Find Project Key:

SELECT project_key FROM sta_project WHERE id = <PROJECT_ID_FROM_QUERY>;

Step 3: Remove the Conflict via REST API

Warning: Do not delete rows directly from the database. Use the REST API to ensure Bitbucket's internal caches are updated. Please check the API documentation on Revoke user project permission and Revoke user repository permission.

If unsure which entry to delete, remove the more granular permission in this order of precedence:(most preferred) repo permissions > project permissions > global permissions (least preferred).

For a Project Permission conflict:

curl -k -u <ADMIN_USER>:<PASSWORD> -X DELETE \ 'https://<BITBUCKET_URL>/rest/api/latest/projects/<PROJECT_KEY>/permissions/users?name=<USER_NAME>'

For a Repository Permission conflict:

curl -k -u <BITBUCKET_ADMIN_USER>:<PASSWORD> -X DELETE \ 'https://<BITBUCKET_URL>/rest/api/latest/projects/<PROJECT_KEY>/repos/<repositorySlug>/permissions/users?name=<USER_NAME>'

At times, this can also occur when the user ID in the global permission does not exist; in that scenario, you will need to first fix the orphaned account and later remove the global permission to resolve the issue. More details in KB: Bitbucket Data Center shows "A database error has occurred" on accessing repository permissions page | Bitbucket Data Center | Atlassian Support

Step 4: Verify and Restore

  1. Refresh the Bitbucket UI to ensure the page loads correctly.

  2. Re-add the permission through the Bitbucket UI if the user still requires that level of access. This will assign a new, unique ID to the record.

Updated on June 1, 2026

Still need help?

The Atlassian Community is here for you.