K2 5.2 Installer is failing with "Object Reference" error on Role in K2 Management
kbt155711
PRODUCTIssue
When opening the K2 Management page and navigating to the Users > Roles the error below will be displayed:
"Object reference not set to an instance of an object."
Symptoms
The K2 Installer trace will be raising the error below:
"System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'Authorization.Role' with unique index 'UX_Authorization_Role_Name'. The duplicate key value is (DomainUser).
The statement has been terminated. at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException) at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)"
Resolution
To determine if there are duplicate Identity and Roles present on the upgrade environment, execute the queries below:
USE [K2]
-- Check for duplicates
SELECT * FROM [Identity].[Identity] where name in ( SELECT Name FROM [Identity].[Identity] GROUP BY name HAVING COUNT(Name) > 1 ) and type=2
--#######################################################
-- Get Identity role to migrate
SELECT [ID],[AuthorizationGuid],[Name],[DisplayName],[Identity].[GetIdentityPropertyValue]([Properties], 'Description') AS [Description]
FROM [Identity].[Identity] WHERE [Type] = 2 AND [ID] < 0
--#######################################################
-- Get Auth Roles
SELECT * FROM [Authorization].[Role]
--#######################################################
Under normal circumstances, no data should be displayed on the check for duplicates query.
Should the results display data, it means that are duplicate references found, which is the cause of the error in K2 Management.
To resolve this issue, direct database modification will be required. Please log a K2 Support Ticket on the K2 Customer Portal for assistance with resolving the issue.
This must only be done with the assistance of, or when instructed to do so by K2 Support. Please see: http://help.k2.com/onlinehelp/k2blackpearl/devref/current/default.htm#Database_Reference.html