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

Inline images are rendering in ADO's Description field for one work item type but not another #1063

Closed cacti77 closed 2 months ago

cacti77 commented 2 months ago

Describe the problem In the source Jira server project I have Bugs and Improvements. Some of these have inline images/screenshots in their Description field. When I import these issues into the target ADO project, the inline images render in the standard Description field of the Improvements but not the Bugs; e.g.: image

To Reproduce Extracts from the config json file:

  "process-template": "Basic",

  "type-map": {
    "type": [
      {
        "source": "Improvement",
        "target": "Myprocess.Improvement"
      },
      {
        "source": "Bug",
        "target": "Myprocess.Bug"
      }
    ]
  },
  "field-map": {
    "field": [
      {
        "source": "description",
        "target": "System.Description",
        "mapper": "MapRendered"
      },

where Myprocess is the name of my ADO process which inherits from Basic. Myprocess has Epic, Issue and Task disabled, but new work item types called Bug and Improvement. Both of these have the default System.Description field but are otherwise virtually identical. Neither WIT has a Repro Steps field (and so I don't refer to that in the config json file either).

When I look in the issue json files generated by jira-export you can see entries like this inside a Myprocess.Improvement's System.Description field:

<p>Bob got this error in his project X today:</p>\n\n<p><span class=\"image-wrap\" style=\"\"><a id=\"402317_thumb\" href=\"/jira02/secure/attachment/402317/402317_image-2024-04-25-14-56-13-943.png\" title=\"image-2024-04-25-14-56-13-943.png\" file-preview-type=\"image\" file-preview-id=\"402317\" file-preview-title=\"image-2024-04-25-14-56-13-943.png\"><img src=\"https://mycompany.com/jira02/secure/thumbnail/402317/_thumb_402317.png\" style=\"border: 0px solid black\" role=\"presentation\"/></a></span></p>

...and this image renders perfectly inside the Description of the Improvement created in ADO.

But inside a Myprocess.Bug's System.Description field all you see is:

<p>I tried running the following lines on a jupyter notebook (IDE= VS code),</p>\n\n<p><img src=\"/jira02/secure/attachment/402834/402834_image-2024-05-20-15-01-45-809.png\" style=\"border: 0px solid black\" /></p>\n\n<p>but I've got the following error, although the graph is still plotted after showing the error.<br/>\n<img src=\"/jira02/secure/attachment/402833/402833_image-2024-05-20-15-03-05-171.png\" style=\"border: 0px solid black\" /></p>\n\n<p>

Note the images are still imported and are visible in the Links section of the ADO Bugs; they just aren't rendered in the Description.

Tool version 3.0.442

Alexander-Hjelm commented 2 months ago

The first thing I notice is that the Type map seems to include the Process name. Is this correct? If the Work Item Types are named simply Bug and Improvement, then the type map should look like the following:

  "type-map": {
    "type": [
      {
        "source": "Improvement",
        "target": "Improvement"
      },
      {
        "source": "Bug",
        "target": "Bug"
      }
    ]
  },
cacti77 commented 2 months ago

Thanks @Alexander-Hjelm. Your suggestion was actually what I tried originally. However, even though both the jira-export and wi-import tools ran without error, no work items appeared in my DevOps project! I nearly raised an issue to ask how does one map to custom WITs; I couldn't find anything in the FAQ about this.

But when I went to https://dev.azure.com/MyOrg/MyProject/_apis/wit/workitemtypes?api-version=7.1 to list the WITs in my project I could see my custom WITs were prefixed with the process name; e.g.:

   {
      "name": "Bug",
      "referenceName": "Myprocess.Bug",

and when I updated my type-map as above the imported WITs then did appear in my ADO project, as required.

Aside: Note that the Basic process doesn't actually have a Bug WIT (see here), so maybe Samples\config-basic.json needs updating not to reference it?

Everything appears to be imported into ADO correctly for both Bugs and Improvements. The only issue is that any inline images are not rendering in the Bugs for some unexplained reason!

Alexander-Hjelm commented 2 months ago

Ok! Can you confirm whether or not this issue is related to https://github.com/solidify/jira-azuredevops-migrator/issues/851?

cacti77 commented 2 months ago

Just looking at the title of that issue, I would say no, because the attached images that should appear inline in the Description are still being imported as attachments. Note too this only affects the Description field of the custom Bug WIT. Any inline images in comments render perfectly well using the default mapping in the config json:

      {
        "source": "comment",
        "target": "System.History",
        "mapper": "MapRendered"
      },

I'll have a deeper look at #851 though...

cacti77 commented 2 months ago

No, I'm pretty sure this has nothing to do with #851. Also, in my original ADO process, which also inherited from Basic, I only had one WIT type - Issue, with a custom field for Bug or Improvement (because at that time I didn't know you could add your own WITs!). The inline images in the Description field rendered fine in the ADO issues for both the 'Bug' and 'Improvement' Issues. It's only since I've created the custom WITs that this isn't happening for the new Bug WIT.

Also, I see nothing unusual in the history of the original Jira bug associated with the screenshot above; the user simply completed the Description and pasted in 2 screenshots. They weren't removed or re-added later on.

Alexander-Hjelm commented 2 months ago

Agreed. I addressed your point about the Bug type in the Basic template in this commit: https://github.com/solidify/jira-azuredevops-migrator/commit/3361bb8f1ef777cc7c772111878ed977ddf50d2d

Here is the CorrectDescription method for reference:

https://github.com/solidify/jira-azuredevops-migrator/blob/3361bb8f1ef777cc7c772111878ed977ddf50d2d/src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs#L442-L480

I can see that the description field seems to be hard coded for various Work Item Types. If the WI Type name is "Bug", then it seems to switch over to using ReproSteps instead of Description. Could this be the underlying issue, do you think?

cacti77 commented 2 months ago

@Alexander-Hjelm Thank you so much for that info! Yes, my original config json above only had the one entry for the "source": "description" field. When I changed it to this:

      {
        "source": "description",
        "target": "System.Description",
    "not-for": "Myprocess.Bug",
        "mapper": "MapRendered"
      },
      {
        "source": "description",
        "target": "Microsoft.VSTS.TCM.ReproSteps",
    "for": "Myprocess.Bug",
        "mapper": "MapRendered"
      },

then the Description field for the new Bug WIT was not populated at all once the issues were imported into ADO. So then I changed the custom Bug WIT in ADO to add a Repro Steps field and hide the Description field: image

Finally, when I ran the importer again the inline images rendered for both my custom Improvements (in the Description field) and Bugs (in the Repro Steps field). Yay, at last! (All tested using 3.0.442 still.)

I guess users just have to be careful that if they create a custom WIT called 'Bug' they have to give it a Repro Steps field rather than a Description field, but the former makes more sense anyway.

Thanks, too, for updating docs/Samples/config-basic.json.

Thank you once again for all your help. This tool is great, buttressed by your timely support, and has really offset the sudden pain of being kicked off a Jira server that's about to be shut down.

Alexander-Hjelm commented 2 months ago

No worries. I will create a new issue to follow up on this. It feels like we should build more general handling for WI/attachment links for all issue types.