ngetchell / PSGitLab

An interface for administering GitLab from the PowerShell command line.
MIT License
72 stars 42 forks source link

Pagination is not handled correctly #168

Closed it-praktyk closed 6 years ago

it-praktyk commented 6 years ago

1. Provide a general summary of the issue in the Title above

Under testing of the code for the pull request I've observed that warning is displayed and not all results are returned

PS > Get-GitLabPipeline -ProjectID 63 -Verbose | measure
VERBOSE: Parameter Set Name: Single
VERBOSE: URL: https://gitlab.example.com/api/v4/projects/63
VERBOSE: GET https://gitlab.example.com/api/v4/projects/63 with 0-byte payload
VERBOSE: received 1854-byte response of content type application/json
VERBOSE: Returning a pipeline(s) for the project ActiveAssistSetup and id 63
VERBOSE: Parameter Set Name: Pipelines
VERBOSE: A prepared API request: /projects/63/pipelines?order_by=id&sort=desc&per_page=100
VERBOSE: URL: https://gitlab.example.com/api/v4/projects/63/pipelines?order_by=id&sort=desc&per_page=100
VERBOSE: GET https://gitlab.example.com/api/v4/projects/63/pipelines?order_by=id&sort=desc&per_page=100 with 0-byte payload
VERBOSE: received 10184-byte response of content type application/json
VERBOSE: GET https://gitlab.example.com/api/v4/projects/63/pipelines?order_by=id&sort=desc&per_page=100?&page=2 with 0-byte payload
VERBOSE: received 31-byte response of content type application/json
WARNING: . See https://gitlab.example.com/help/api/README.md#status-codes for more information.

Count    : 100
Average  :
Sum      :
Maximum  :
Minimum  :
Property :

after commenting lines

<OUTPUT_PARTIALY_OMITTED>
VERBOSE: GET https://gitlab.example.com/api/v4/projects/63/pipelines?order_by=id&sort=desc&per_page=100?&page=2 with 0-byte payload
VERBOSE: received 31-byte response of content type application/json
Invoke-WebRequest : {"error":"per_page is invalid"}
At <FOLDER_PATH>\PSGitLab\PSGitLab\Private\QueryGitLabAPI.ps1:52 char:22
+         $Results += (Invoke-WebRequest @newRequest).Content | Convert ...
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (Method: GET, Re...rShell/6.0.2
}:HttpRequestMessage) [Invoke-WebRequest], HttpResponseException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Count    : 100
<OUTPUT_PARTIALY_OMITTED>

2. Describe Your Environment

Windows 10 x64 PowerShell Core 6.0.2 GitLab 10.7.3 - API v4

3. Expected Behavior

5. Possible Solution

I'll provide a proposed fix as a separate pull request.

ngetchell commented 6 years ago

Fixed by @it-praktyk