Unable to edit or remove one of the contexts defined for a customfield under customfield configurations
プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。
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.
*Fisheye および Crucible は除く
要約
Sometimes users experience an issue where they are not able to modify/remove already defined customfield contexts. This is specifically noticed during migrations and XML restores from other instances where some of the crucial information required might be missing like issuetype mappings, project mappings missing for some contexts.
環境
Jira 8.X and 9.X versions.
診断
The data associated with the customfields configuration in Jira is majorly stored in these core tables:
- customfield
- customfieldvalue
- customfieldoption
- genericconfiguration
- fieldconfigscheme
- configurationcontext
- fieldconfigschemeissuetype
Out of these contexts mapping is more specifically related to 'fieldconfiguration', 'fieldconfigscheme', 'fieldconfigschemeissuetype'.
Documentation Reference: Jira Database Modelling – Custom fields
When one of the values is missing or not available in these tables, the changes will be reflected in the GUI. However, when you try to modify the customfield context in the GUI, it throws the errors like below. In such scenarios we need to validate the data from above mentioned table to identify the missing information and accordingly update it to fix the issue and allow the users to make next set of changes.
When trying to delete the customfield context which is not mapped with any issuetypes and projects, system throws 'Nullpointer' exceptions and below logs can be observed from the application logs.
2023-07-05 11:48:50,655+0000 http-nio-8080-exec-13 url: /internal-error ERROR [c.a.j.web.servlet.InternalServerErrorServlet] {errorId=be7ece86-c6a3-46fb-821b-d1b679e29303, interpretedMsg=, cause=java.lang.NullPointerException, stacktrace=java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:889) [guava-31.0.1-jre.jar:?]
at com.google.common.collect.SingletonImmutableList.<init>(SingletonImmutableList.java:39) [guava-31.0.1-jre.jar:?]
If you try to edit the customfield context by adding issuetypes and projects, error is thrown when trying to update and save the customfield context.
2023-07-05 11:49:48,595+0000 http-nio-8080-exec-36 ERROR [o.a.c.c.C.[.[localhost].[/].[action]] Servlet.service() for servlet [action] in context with path [] threw exception [java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0] with root cause
java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at com.atlassian.jira.web.action.admin.customfields.ManageConfigurationScheme.doExecute(ManageConfigurationScheme.java:213)
at webwork.action.ActionSupport.execute(ActionSupport.java:165)
原因
This is generally caused by missing one of the entries in the associated tables with the customfield contexts which are 'fieldconfiguration', 'fieldconfigscheme', 'fieldconfigschemeissuetype'. We need to validate the entries for these tables for the corresponding customfield being impacted. Below queries are helpful in validation.
Get the problematic customfield id by running below query, replace <Impacted Customfield Name> with the name of your customfield.
SELECT id FROM customfield WHERE cfname = '<Impacted Customfield Name>';
When you create a customfield context, it will be saved in these 2 tables 'fieldconfiguration' and 'fieldconfigscheme'. For any customfield there will be a default context and we can add number of contexts based on preference. So validate the entries present in these tables. Number of contexts entries in the customfield configuration should match number of entries for that specific customfield in these 2 tables.
SELECT id from fieldconfiguration where fieldid = 'customfield_<value from above query>'; SELECT id from fieldconfigscheme where fieldid = 'customfield_<value from above query>';
When we associate an issuetype to any context, it will be stored in the 'fieldconfigschemeissuetype' table for that specific context. Validate if there are entries mapped to the problematic customfield context, we believe this should be missing in the database when the problem mentioned above will be happening.
SELECT * FROM fieldconfigschemeissuetype where fieldconfigscheme = '<id of the impacted customfield context>';
ソリューション
データベースの変更を行う場合は必ず事前にバックアップを取得してください。可能な場合は、まずステージング サーバーで SQL コマンドの変更、挿入、更新、または削除を行うようにします。
In order to fix the problem with missing field context entries in the database tables, we need to execute below set of actions to ensure we have valid entries in the tables after which the system will allow the deletion of problematic customfield context.
Use the database queries matching your database variant or the GUI based tool to update the tables as specified.
Run the below query to validate the number of contexts associated with the problematic customfield and focus on the problematic context which can't be deleted. In our use-case for validation, we have 'customfield_XXXXX' with 2 contexts.
SELECT id from fieldconfigscheme WHERE fieldid = 'customfield_XXXXX'; --> XXXXX is the value of customfield id. 10407 10801
While there is missing entry in the 'fieldconfiguration' table for the problematic context, we need to manually create an entry with missing 'id' returned from results of above query. In our local testing, it's 10801 which is missing.
SELECT id from fieldconfiguration where fieldid = 'customfield_XXXXX'; 10407
- While updating the 'fieldconfiguration' table to populate the missing 'id' which is 10801, we can use existing 'configname' and 'description' values to update the data in the tables, the crucial information is the missing id. Once we update the table, it should look like below.
Now validate the entries from 'fieldconfigschemeissuetype' to map an issue-type to the problematic context which is missing. Check the issue-type matched to other context of same customfield, in this case context id is 10407.
SELECT * from fieldconfigschemeissuetype where fieldconfigscheme = '<impacted_id>'; SELECT * from fieldconfigschemeissuetype where fieldconfigscheme = '10801'; --> In our testing impacted fieldconfigscheme id is 10801.
Observe the missing value for 'issuetype' in below screenshots, we need to update one of the issuetype id's to fix this gap. We used the id '10004' used in other context which is 'Bug'.
SELECT * from fieldconfigschemeissuetype where fieldconfigscheme = '<impacted_id>'; SELECT * from fieldconfigschemeissuetype where fieldconfigscheme = '10801'; --> In our testing impacted fieldconfigscheme id is 10801.
- Once we fix the table entries, now go ahead to GUI and try to remove the impacted customfield and it's context. You should be able to modify or delete it without any issues.
Changes should be immediately effective. If you experience any issues, restart the instance once as the exercise involves database changes which the system needs to catch-up.