Searching by a custom field with invalid value/option results in "NullPointerException" on "customfields.manager.DefaultOptionsManagerDefault"

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When performing a search including a custom field with null value or if there are invalid entries in the customfieldoption table, JIRA will throw out the following error:

java.lang.NullPointerException
at com.atlassian.jira.issue.customfields.manager.DefaultOptionsManager.findByOptionValue(DefaultOptionsManager.java:164)
at com.atlassian.jira.issue.customfields.manager.CachedOptionsManager.findByOptionValue(CachedOptionsManager.java:95)
at com.atlassian.jira.jql.util.JqlSelectOptionsUtil.getOptionFromString(JqlSelectOptionsUtil.java:208)
at com.atlassian.jira.jql.util.JqlSelectOptionsUtil.getOptions(JqlSelectOptionsUtil.java:135)

Cause

#1

There is a null value in the customfieldoption table. When a search is performed, it will search for all the custom field value options, so, if any of the values is null it will throw out an error.

#2

There are entries in the customfieldoption table that do not correspond to any custom field.

Resolution

#1

  1. Perform the following query in JIRA's database, then take note of the custom fields returned;

    SELECT 
    	c.cfname AS "Custom Field",
    	o.customvalue AS "Value"
    FROM
    	customfield c
    	JOIN customfieldoption o ON c.id = o.customfield 
    WHERE
    	customvalue IS NULL;
  2. Go to AdministrationIssues > Custom Field;
  3. Click Configure on the right of each custom field returned by the query above;
  4. Delete any null option;

If the above fails to resolve the issue, proceed with the deletion of the null value directly on the database. For that, use the following query:

DELETE FROM customfieldoption WHERE customvalue is null;

Always back up your data before performing any modification to the database. If possible, try your modifications on a test server.

Restart JIRA for changes to take effect.

#2

  1. Perform the following query on JIRA's database to check if there are invalid entries on the customfieldoption table;

    SELECT
    	customfield
    FROM
    	customfieldoption
    WHERE
    	customfield NOT IN (
    		SELECT 
    			id
    		FROM
    			customfield
    		);
  2. If the above query returns any result, run the query below;

    DELETE
    FROM
    	customfieldoption
    WHERE
    	customfield NOT IN (
    		SELECT
    			id
    		FROM
    			customfield
    		);

Restart JIRA for changes to take effect.

Last modified on Dec 13, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.