solidify / jira-azuredevops-migrator

Tool to migrate work items from Atlassian Jira to Microsoft Azure DevOps/VSTS/TFS.
MIT License
264 stars 228 forks source link

Jira export - Unexpected migration error. [System.InvalidCastException] #1056

Closed smorrisonk closed 3 months ago

smorrisonk commented 4 months ago

Describe the problem

I getting an error when trying to export issues from Jira;

Unexpected migration error. [System.InvalidCastException] System.InvalidCastException: Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken.

From my research it could have to do with my local json-file failing to parse(?) but I need help on how to solve the issue.

To Reproduce

The command I'm running (on Mackbook, using Wine to run the file) is "wine jira-export.exe -u myUerEmail -p myJiraToken --url https://jiraWorkspace.atlassian.net --config config-basic.json --force"

Tool version jira-azuredevops-migrator-3.0.426

Attachments

Please attach the following files: config-basic.json error-message.txt

Alexander-Hjelm commented 4 months ago

The exception is raised inside the getter for EpicParent, on JiraItem.cs:

https://github.com/solidify/jira-azuredevops-migrator/blob/c52b270468e7e7f285f4ec5046a7719d392b4720/src/WorkItemMigrator/JiraExport/JiraItem.cs#L596-L605

This in turn calls the ExValue extension method on a JObject, when ExValue is only defined for the type JToken:

https://github.com/solidify/jira-azuredevops-migrator/blob/c52b270468e7e7f285f4ec5046a7719d392b4720/src/WorkItemMigrator/Migration.Common/JsonExtensions.cs#L9-L23

Do you have any previous experience of getting the JiraExporter to work on mac? We do not officially support MacOS yet, and I would recommend running the CLI in a Windows VM instead.

jbparker commented 4 months ago

Windows user here running into the same exception:

[System.InvalidCastException] System.InvalidCastException: Cannot cast Newtonsoft.Json.Linq.JObject to Newtonsoft.Json.Linq.JToken.
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Migration.Common.JsonExtensions.ExValue[T](JToken token, String path)
   at JiraExport.JiraItem.get_EpicParent()
   at JiraExport.JiraProvider.<EnumerateIssues>d__30.MoveNext()
   at JiraExport.JiraCommandLine.ExecuteMigration(CommandOption user, CommandOption password, CommandOption token, CommandOption url, CommandOption configFile, Boolean forceFresh, CommandOption continueOnCritical):
   at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
   at Newtonsoft.Json.Linq.Extensions.Value[T,U](IEnumerable`1 value)
   at Newtonsoft.Json.Linq.Extensions.Value[U](IEnumerable`1 value)
   at Migration.Common.JsonExtensions.ExValue[T](JToken token, String path)
   at JiraExport.JiraItem.get_EpicParent()
   at JiraExport.JiraProvider.<EnumerateIssues>d__30.MoveNext()
   at JiraExport.JiraCommandLine.ExecuteMigration(CommandOption user, CommandOption password, CommandOption token, CommandOption url, CommandOption configFile, Boolean forceFresh, CommandOption continueOnCritical)
jbparker commented 4 months ago

Looks like it is related to this: Upcoming changes: 'epic-link' replaced with 'parent'

Can see a demo of the new complex object parent here: .NET fiddle

That said, there is usually another custom field in the payload that represents the old epic-link field that can be used for instead of the parent field.

Alexander-Hjelm commented 4 months ago

@jbparker @smorrisonk Ok, my bad! :)

Do you have any more details on how to create/modify a Jira issue in order to reproduce this error message? Does it always happen when you add an epic link to an issue?

Any issue histories if available would be helpful!

github-actions[bot] commented 3 months ago

This issue is stale because it has been open for 25 days with no activity.

github-actions[bot] commented 3 months ago

This issue was closed because it has been inactive for 5 days since being marked as stale.