AtlassianPS / JiraPS

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

Paging is broken for Get-JiraIssueComment #398

Open tomcart90 opened 4 years ago

tomcart90 commented 4 years ago

We ran into an issue this week due to Get-JiraIssueComment being completely broken for us in versions prior to the following change: https://github.com/AtlassianPS/JiraPS/commit/76f2156627587c4fae371a5f6d3a350bd986ca9d#diff-3d2c0736f2b14e5401333a532d785924. With Paging set to $true the function seems to end up searching jira for comments endlessly. With Paging set to $false the function works as expected.

spascoe commented 3 years ago

Hi tomcart90,

I performed a simple test using Get-JiraIssueComment as follows:

$cred = Get-Credential 'user'
New-JiraSession -Credential $cred

# 'Key-001' is a placeholder, use a valid story in your system.
Get-JiraIssue 'Key-001' | Get-JiraIssueComment -Verbose

Note $PageSize is currently undefined. The result of the command looks like this

VERBOSE: [Get-JiraIssueComment] Function started
VERBOSE: [Invoke-JiraMethod] Function started
VERBOSE: [ConvertTo-GetParameter] Making HTTP get parameter string out of a hashtable
VERBOSE:
Name                           Value
----                           -----
maxResults

VERBOSE: [Get-JiraSession] Function started
VERBOSE: [Get-JiraSession] Using Session saved in PrivateData
VERBOSE: [Get-JiraSession] Complete
VERBOSE: [Invoke-JiraMethod] Get https://jira.somewhere.com/rest/api/2/issue/9999999/comment?maxResults=
VERBOSE: [Test-ServerResponse] Checking response headers for authentication errors
VERBOSE: [Invoke-JiraMethod] Status code: 200
VERBOSE: [Invoke-JiraMethod] Invoking pagination [currentTotal: 0]

This returned the 5 comments on my sample story.

I then set $PageSize=3, in order to split up the list into two pages. It looks like it worked correctly for me.
In the first page maxResults=3, and I got 3 comments. In the second page, maxResults = 3, startAt = 3, and I got an additional two comments as expected.

I would recommend that you try running with the -Verbose parameter specified to see what additional things might be going on for you.

HTH, Scott