-
Bug
-
Resolution: Fixed
-
Low
-
5.14.0
-
1
-
Severity 3 - Minor
-
Issue Summary
The Assets attribute type "Project" breaks the object history when a project is deleted.
This is reproducible on Data Center: Yes
Steps to Reproduce
- Create an attribute of the type "Project" in an object type
- Create a dummy project
- Set the Object Project attribute to the dummy project.
- Set it to any other project
- Set the Object Project attribute to the dummy project again. The idea is to populate the history
- Delete the dummy project
- The object view will present an error popup and the history won't display, with the error "Could not receive history due to technical problems"
Expected Results
The history should load with all entries
Actual Results
The below exception is thrown in the atlassian-jira.log file:
/rest/insight/1.0/object/4559/history [c.r.j.p.i.services.util.ServiceUtil] RuntimeException:Cannot invoke "com.atlassian.jira.project.Project.getId()" because "project" is null java.lang.NullPointerException: Cannot invoke "com.atlassian.jira.project.Project.getId()" because "project" is null at com.atlassian.jira.security.PermissionsCache.computePermissionIfAbsent(PermissionsCache.java:48)
Workaround
You can remove the "invalid" entries from the NEW_KEY_VALUES and OLD_KEY_VALUES from the History database table AO_8542F1_IFJ_OBJ_HIST
Please backup your Jira database before doing this. We recommend trying it in a test instance first.
1 - Identify the rows from the AO_8542F1_IFJ_OBJ_HIST table that contain entries that don't exist anymore as project IDs:
Query for NEW_KEY_VALUES column (Tested in Postgres):
select o."ID", o."NEW_KEY_VALUES", substring(o."NEW_KEY_VALUES" from '"integerValue":([0-9]+)') as "NEW_KEY_VALUES_projID" from "AO_8542F1_IFJ_OBJ_HIST" as o where "AFFECTED_ATTRIBUTE" = 'Project' and substring(o."NEW_KEY_VALUES" from '"integerValue":([0-9]+)')::INTEGER is not null and substring(o."NEW_KEY_VALUES" from '"integerValue":([0-9]+)')::INTEGER not in (select project_id from project_key)
Query for OLD_KEY_VALUES column (Tested in Postgres):
select o."ID", o."OLD_KEY_VALUES", substring(o."OLD_KEY_VALUES" from '"integerValue":([0-9]+)') as "OLD_KEY_VALUES_projID" from "AO_8542F1_IFJ_OBJ_HIST" as o where "AFFECTED_ATTRIBUTE" = 'Project' and substring(o."OLD_KEY_VALUES" from '"integerValue":([0-9]+)')::INTEGER is not null and substring(o."OLD_KEY_VALUES" from '"integerValue":([0-9]+)')::INTEGER not in (select project_id from project_key)
2 - Remove the values from the NEW_KEY_VALUES and OLD_KEY_VALUES columns for the rows with the IDs identified in the above queries.
The values from these columns should look like this:
- NEW_KEY_VALUES:
{"values":[{"integerValue":10101}]}
- OLD_KEY_VALUES:
{"values":[{"id":907,"integerValue":10101}]}
With this, the history will load again.
Note that you should keep the NEW_VALUE and OLD_VALUE column values.
Note that this workaround will cause the history entry to the deleted project to lose its internal project reference (but it will keep the project name in the history display)
- links to