Errors when trying to display or edit filters with broken JQL

Still need help?

The Atlassian Community is here for you.

Ask the community


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

Summary

Due to invalid JQL stored in a Jira filter's or board quick filter's content, loading pages containing that filter fail with an error 500. Often, NoViableAltException  is shown.

Environment

Jira Server or Jira Data Center

Diagnosis

Any attempt to load or edit filters will fail with 500 errors, internal server configuration errors, or uncaught exceptions.

For example, viewing the Manage Filters page will not work, and an error like the following will be displayed:

com.atlassian.cache.CacheException: com.atlassian.jira.exception.DataAccessException: com.atlassian.jira.jql.parser.JqlParseException: com.atlassian.jira.jql.parser.antlr.RuntimeRecognitionException: NoViableAltException(59@[])


Cause

The JQL in one or more filters' database entry has an invalid syntax.  This will cause most screens that use filters, even unrelated filters, to fail to load.  Editing or even removing the broken filters via the REST API may also fail.
Because it is not possible to save a filter with invalid JQL through the Jira interface, the underlying cause of this problem in the database is unknown in these situations.

Solution

(warning) Note that manual manipulation of the database can be dangerous. Please make sure you have a backup of your database before you attempt these changes.

(info) If possible, the filter should be edited (or deleted) with the REST API as described in the REST API Filter documentation. Direct database edits should be used as a last resort.

(info) The following statements are written for postgres and may need to be modified to work in other database systems.

  1. Identify the filter with the invalid JQL by checking the filter and quick filter tables:
    1. SELECT id, filtername, reqcontent FROM searchrequest;
      SELECT id, "LONG_QUERY" FROM "AO_60DB71_QUICKFILTER";
      1. find the filter with the invalid JQL statement in the reqcontent and/or LONG_QUERY columns
    2. if the error message contains a filter id, you may wish to look it up directly like so:
      1. SELECT id, filtername, reqcontent FROM searchrequest WHERE id = <filter_id_here>;
        id     | filtername   | reqcontent
        -------+--------------+-----------------------------
        10100  | brokenfilter | invalid jql "@" /$ \ ? here
      2. SELECT * FROM searchrequest;
        id     | filtername            | authorname    | description | username      | groupname | projectid | reqcontent                       | fav_count | filtername_lower
        -------+-----------------------+---------------+-------------+---------------+-----------+-----------+----------------------------------+-----------+-----------------------
        10000  | Filter for DEVL board | JIRAUSER10000 |             | JIRAUSER10000 |           |           | project = DEVL ORDER BY Rank ASC | 9001      | filter for devl board
        10100  | brokenfilter          | JIRAUSER10000 |             | JIRAUSER10000 |           |           | invalid jql "@" /$ \ ? here      | 1         | brokenfilter
  2. Edit the database record in question to set the filter content to a valid JQL
    1. For a filter:

      UPDATE searchrequest SET reqcontent = 'project = PROJKEY' WHERE id = <filter_id_here>;
    2. For a board Quick Filter:

      UPDATE "AO_60DB71_QUICKFILTER" SET LONG_QUERY = 'project = PROJKEY' WHERE id = <quick_filter_id_here>;
  3. Confirm that the previously problematic page works as expected




Last modified on Nov 3, 2022

Was this helpful?

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