From eabcaeb06c53f1492f1687418db39ae7354f4f7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madis=20K=C3=B5osaar?= Date: Fri, 31 Jul 2020 11:05:55 +0300 Subject: [PATCH] Feature/null ref fix on adding link (#265) * fixing bug to handle null ref exception when adding link during import * Dont add epic child link if Child link configuration missing. Show meaningful error. --- src/WorkItemMigrator/JiraExport/JiraMapper.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/WorkItemMigrator/JiraExport/JiraMapper.cs b/src/WorkItemMigrator/JiraExport/JiraMapper.cs index 7f0f9782..9e189037 100644 --- a/src/WorkItemMigrator/JiraExport/JiraMapper.cs +++ b/src/WorkItemMigrator/JiraExport/JiraMapper.cs @@ -84,12 +84,17 @@ private void AddSingleLink(JiraRevision r, List links, string field, str var changeType = value == null ? ReferenceChangeType.Removed : ReferenceChangeType.Added; var linkType = (from t in _config.LinkMap.Links where t.Source == type select t.Target).FirstOrDefault(); - // regardless if action is add or remove, as there can be only one, we remove previous epic link if it exists if (changeType == ReferenceChangeType.Added) { string linkedItemKey = (string)value; + if (string.IsNullOrEmpty(linkType)) + { + Logger.Log(LogLevel.Warning, $"Cannot add 'Child' {linkedItemKey} link to 'Parent' {r.ParentItem.Key}, 'Child' link-map configuration missing."); + return; + } + var link = new WiLink() { Change = changeType,