AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
321 stars 131 forks source link

(Get-JiraIssue).Comment inconsistent #436

Open agowa opened 3 years ago

agowa commented 3 years ago

Description

(Get-JiraIssue).Comment is inconsistent. There are two different data structures.

There are no comments

ConvertTo-Json -InputObject $ticket1.comment -Depth 1

{
  "comments": [],
  "maxResults": 0,
  "total": 0,
  "startAt": 0
}

There are one or more comment

ConvertTo-Json -InputObject $ticket2.comment -Depth 1

[
  {
    "Author": "agowa338",
    "Created": {
      "value": "2021-03-21T02:55:40.434+01:00",
      "DisplayHint": 2,
      "DateTime": "Sonntag, 21. März 2021 02:55:40"
    },
    "UpdateAuthor": "agowa338",
    "Visibility": null,
    "Updated": {
      "value": "2021-03-21T02:55:40.434+01:00",
      "DisplayHint": 2,
      "DateTime": "Sonntag, 21. März 2021 02:55:40"
    },
    "Body": "aa",
    "ID": "108",
    "RestUrl": "https://$Server/rest/api/2/issue/27/comment/108"
  }
]

Steps To Reproduce

  1. Create two issues.
  2. Add one comment to the 2nd issue.
  3. $ticket1 = Get-JiraIssue -Key SPACE-1
  4. $ticket2 = Get-JiraIssue -Key SPACE-2
  5. Investigate the data structure of the comment attribute of both issues

Expected behavior

Consistent data structure. From looking at the 0-comment data structure I guess some assignment is going wrong.

I'd expect to see this structure for an issue with one and more comments.

{
  "comments": [
    {
      "Author": "agowa338",
      "Created": {
        "value": "2021-03-21T02:55:40.434+01:00",
        "DisplayHint": 2,
        "DateTime": "Sonntag, 21. März 2021 02:55:40"
      },
      "UpdateAuthor": "agowa338",
      "Visibility": null,
      "Updated": {
        "value": "2021-03-21T02:55:40.434+01:00",
        "DisplayHint": 2,
        "DateTime": "Sonntag, 21. März 2021 02:55:40"
      },
      "Body": "aa",
      "ID": "108",
      "RestUrl": "https://$Server/rest/api/2/issue/27/comment/108"
    }
  ],
  "maxResults": 1,
  "total": 1,
  "startAt": 0
}

Your Environment

Name   Version
----   -------
JiraPS 2.14.6

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.21337
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Possible Solution

Find where the incorrect attribute assignment is happening and fix it.