Uploaded image for project: 'Jira Server and Data Center'
  1. Jira Server and Data Center
  2. JRASERVER-65734

JIRA incorrectly uses fieldconfigscheme ID instead of fieldconfiguration ID to look up Custom Field Options

    XMLWordPrintable

    Details

      Description

      Scenario

      When a (new) custom field context is created for a custom field of type Select List (single choice), JIRA creates the following entries in the database:

      • 1 entry in table fieldconfiguration to store the context itself
      • 1 entry in table fieldconfigscheme to store the context scheme
      • X entries in table fieldconfigschemeissuetype to link the above 2 together, plus the issue type context (restricted to which issue type/s)
      • X entries in table configurationcontext to store the project context (restricted to which project/s)
      • X entries in table customfieldoption to store the number of options
      • 1 entry in table genericconfiguration to store the default value (if any)

      For example, this custom field context (created when custom field is created):

      has these entries in the database:

      The relationships between the tables and columns are as follows:

      • fieldconfigscheme.id = fieldconfigschemeissuetype.fieldconfigscheme = configurationcontext.fieldconfigscheme 
      • fieldconfiguration.id = fieldconfigschemeissuetype.fieldconfiguration = genericconfiguration.datakey
      • fieldconfiguration.id = customfieldoption.customfieldconfig

      Problem

      According to the above, there's no relationship between fieldconfigscheme.id and fieldconfiguration.id, and they do mismatch. Currently, when JIRA needs to look up customfieldoption.customfieldconfig for available options, it fails because it incorrectly uses fieldconfigscheme.id instead of fieldconfiguration.id, leading to options not found.

       So far this is known to cause only Project Import problem, as in JRASERVER-63226.

      Steps to reproduce

      1. Create a custom field as in the above example
      2. Modify the database to make fieldconfigscheme.id differ from fieldconfiguration.id:
        1. update fieldconfigscheme set id = 99999 where id = 10500;
        2. update fieldconfigschemeissuetype set fieldconfigscheme = 99999 where fieldconfigscheme = 10500;
        3. update configurationcontext set fieldconfigscheme = 99999 where fieldconfigscheme = 10500;

        This is for testing purpose only, but it happens in real situations.

      3. Restart JIRA for the change to take effect
      4. Create an issue that the field is available for, and give the field a value in that issue e.g. Peugeot
      5. Create an XML backup
      6. Delete the issue in step 4 to make the project ready for project import
      7. Use the backup in step 5 to perform a project import

      Expected behavior

      There's no validation error regarding the custom field options, because the custom field exists with exactly the same context and options.

      Actual behavior

      JIRA says it can't find the option Peugeot needed to import the issue:

      JIRA uses 99999 to look up the options, but the options use 10500.

      Workaround

      It's possible to modify the entities.xml and update customfieldoption.customfieldconfig with fieldconfigscheme.id. In this example, find the following lines:

      <CustomFieldOption id="10300" customfield="10200" customfieldconfig="10500" sequence="0" value="Peugeot" disabled="N"/>
      <CustomFieldOption id="10301" customfield="10200" customfieldconfig="10500" sequence="1" value="Honda" disabled="N"/>

      and replace them with:

      <CustomFieldOption id="10300" customfield="10200" customfieldconfig="99999" sequence="0" value="Peugeot" disabled="N"/>
      <CustomFieldOption id="10301" customfield="10200" customfieldconfig="99999" sequence="1" value="Honda" disabled="N"/>

      Then save the file, zip it back, and use the zip to perform project import.

       The modified zip file should only be used for project import. Once done, it should be destroyed as the custom field configuration association is already messed.

       For more details, please refer to Project Import fails due to missing Custom Field Options.

        Attachments

        1. db.png
          db.png
          28 kB
        2. field.png
          field.png
          15 kB
        3. import.png
          import.png
          25 kB

          Issue Links

            Activity

              People

              Assignee:
              pdrygas Pawel Drygas (Inactive)
              Reporter:
              vdung Andy Nguyen (Inactive)
              Votes:
              14 Vote for this issue
              Watchers:
              27 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: