Import Error: No 'key' field for Issue #####

I was originally attempting to do a system restore but after two failed attempts (no longer being able to access Jira), I restored to doing a project import as a test.

I each time I do a project import, I get the following errors:

There was a problem parsing the backup XML file at /var/atlassian/application-data/jira/import/Cloud2.zip: No 'key' field for Issue 26021.

There was a problem parsing the backup XML file at /var/atlassian/application-data/jira/import/Cloud2.zip: No 'key' field for Issue 35418.

What do I need to do to resolve these errors?

3 answers

The problem is that you cannot pull a backup straight out of the cloud and import projects into a server version. If you are performing a cloud to server merge/migration or cloud to cloud merge/migration these are steps are required.

Here are the steps to avoid this issue for both operations:

  1. Pull back from source cloud
  2. Run atlassian-xml-cleaner.jar 
    1. Do this every time, regardless if you feel your not going to get an error, it will save you time in the long run.
  3. Stand up a cloud-source-stage "on-prem" server
  4. Restore cleaned backup and attachments
  5. Backup restored cloud-source-stage
  6. Transfer backup and attachments to target-stage
  7. Import projects and attachments to target-stage
    1. Restore to prod-target cloud if going in to Cloud
    2. Restore to Prod Target if going to server.

Hope this helps,

Dan Buffham, ACP

0 votes

I'm afraid this is a bit of a "circular answer".  Your backup is missing data for the field "key", so the project import cannot import it.  The reason it is missing is that you've manged to create an export with missing key data.  So what you need is a valid backup with that data.

hi Nic, Unfortunately i am having the same issue. I back uped the JIRA cloud instance by login in System Admin

System-->BAckup Manager--> Create backup for Server (Since i am try to restore this in Server Instance.

Not sure what i am missing.

 

Regards,

Abhishek

Have you solved thisi issue?

I'm having the same issue too when trying to restore into server instance (backup is from cloud)

I had to change the permission levels for the "jira" folder on the server to allow access to the account I was using.

I don't know if this is how all systems are set up, but this is what I did. My DevOps guy gave me the ip address & login credentials needed to access the server.

1. Using Putty, I changed the Jira folder permissions to allow my account (provided by DevOps) full access.

2. Using WinSCP, uploaded the zip files to the import folder & attachments folder.

3. Changed the Jira folder permissions back to its original settings.

4. Ran the Project Import

I can't remember if that solved this particular problem but I do remember it being a necessary step.

Hi everyone,

I've successfully imported a Jira cloud project to a Jira 7.8.0 server.

There is a little python 3 script that do the job:

import sys
import codecs
import os

inputFile = "entities.xml"
outputFile = "entities.xml.new"

numberString = "number=\""
numberStringSize = len(numberString)
projectString = "project=\""
projectStringSize = len(projectString)
issueIdString = "<Issue id=\""
issueIdStringSize = len(issueIdString)
stringDelimiter = '"'
keyString = "key=\""
# To fill the dictionary "projectKeyMap", you need to get all the Cloud projects ID and projects Key.
# This can be found in the entities.xml. Search for "<Project id=" in the file and built the dictionary.
# or improve this script to auto generate it from the entities.xml file dynamically
projectKeyMap = {"10000": "ABC","10100": "DEF","10200": "GHI"}

counter = 0
with codecs.open(inputFile, 'r', encoding='utf-8') as fi, \
codecs.open(outputFile, 'w', encoding='utf-8') as fo:
for line in fi:
counter += 1
# update versions of jira and plugins
line = line.replace('#cloud build n°', '#server build n°')
line = line.replace('cloud version', 'server version')
line = line.replace('<OSPropertyString id="specific cloud id" value="cloud build n°"/>','<OSPropertyString id="specific cloud id" value="server build n°"/>')
line = line.replace('cloud plugin 1 version', 'server plugin 1 version')
line = line.replace('cloud plugin 2 version', 'server plugin 2 version')
line = line.replace('cloud plugin x version', 'server plugin x version')

# Add missing "key" in the <issue> entries
if line.find(issueIdString) > 0 and line.find(keyString) == -1:
# Get issue number
tmpLine = line[line.find(numberString)+numberStringSize:]
issueNum = tmpLine[0:tmpLine.find(stringDelimiter)]
# Get project ID
tmpLine = line[line.find(projectString) + projectStringSize:]
projectId = tmpLine[0:tmpLine.find(stringDelimiter)]
# Build issue Key
if len(projectId) > 7:
sys.stderr.write("{0}\n".format(counter))
sys.stderr.write("project id = {0}".format(projectId))
issueKey = "{0}-{1}".format(projectKeyMap[projectId], issueNum)
keyEntry = "{0}{1}{2}".format(keyString, issueKey, stringDelimiter)
# Get issue id
tmpLine = line[line.find(issueIdString) + issueIdStringSize:]
issueId = tmpLine[0:tmpLine.find(stringDelimiter)]
# Build string to replace and replacement string
stringToReplace = "{0}{1}{2}".format(issueIdString, issueId, stringDelimiter)
replacementString = "{0} {1}".format(stringToReplace, keyEntry)
# Replace string
line = line.replace(stringToReplace, replacementString)
# Replace priority labels
line = line.replace('"Blocker"', '"Highest"')
line = line.replace('"Critical"', '"High"')
line = line.replace('"Major"', '"Medium"')
line = line.replace('"Minor"', '"Low"')
line = line.replace('"None"', '"Low"')
# Write data
fo.write(line)

# Remove old file and replace it by the new generated one
os.remove(inputFile)
os.rename(outputFile, inputFile)

 

You will need to adapt it depending of the jira cloud version at the moment you try this andyour jira server version.

I use this file to update many infos that may differ from cloud to server such as:

  • username 
  • priorities
  • Status
  • Customfield names
  • etc...

 

Works like a charm for me.

 

cheers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

467 views 7 5
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you