Searching for Jira issue by custom field value results in NullPointerException

Platform Notice: Data Center Only - This article only applies to Atlassian products 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

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

Scenario 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.

Scenario 2

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

Root cause

It is yet unclear how custom field options may become unassociated from their fields, or end up with null values.

It is speculated that instability on the database connection or a Jira ungraceful termination while an operation on them was taking place could eventually lead to these residues on the database.

Alternatively, they could also be a result of direct database manipulation or database type conversion errors.

However, it was not possible to audit their origin any further.

Resolution

After performing the steps below, if the issue persists after the reboot, ensure to run a Full re-index of the instance and verify.

Scenario 1 - UI

  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 Administration > Issues > Custom Field;

  3. Click Configure on the right of each custom field returned by the query above;

  4. Delete any null option;

Scenario 1 - Database

Always back up your data before making any database modifications. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.

  1. 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;
  2. Restart JIRA for changes to take effect.

Scenario 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 );
  3. Restart JIRA for changes to take effect.

Updated on May 22, 2025

Still need help?

The Atlassian Community is here for you.