microsoftgraph / microsoftgraph/msgraph-sdk-powershell

Implementation of the paging is incorrect

Open
#2,869 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Status: Needs Investigation
Dominant language
C#
Stars
898
Forks
230
Avg merge
2d 5h
Merged PRs (30d)
31

Description

Describe the bug

When used together, -Top and -PageSize return incorrect number of items when $topValue cannot be divided by $PageSizeValue without a remainder.

# it returns 4 items, although 3 items are requested; `4 items = 2 pages X 2 items` instead of `3 items = (1 page X 2 items) + 1 item`
PS> get-mguser -top 3 -PageSize 2

DisplayName        Id                                  
-----------        --                                  
Abby Brown2        7d1a89a8-0029-4e19-a256-cac05295a1
Adele Mance        ac4de573-e369-4dcb-bbd2-170c4a0b66
Adele Vance        7ff931dc-2ecf-4e51-8e0b-04e7aaf347
Aleksandar Nikolic cc6166e6-acf1-419b-b06d-f44abb945b

# returns 9 items although 7 items are requested; `9 items = 3 pages X 3 items` instead of `7 items = (2 pages X 3 items) + 1 item`
PS> get-mguser -top 7 -PageSize 3

DisplayName        Id                                  
-----------        --                                  
Abby Brown2        7d1a89a8-0029-4e19-a256-cac05295a1
Adele Mance        ac4de573-e369-4dcb-bbd2-170c4a0b66
Adele Vance        7ff931dc-2ecf-4e51-8e0b-04e7aaf347
Aleksandar Nikolic cc6166e6-acf1-419b-b06d-f44abb945b
Aleksandar Nikolic 177fdb14-fa62-4d84-a8fb-bd635c3981
Alex Wilber        3626d3fe-5bf7-4f85-9e40-9fd5a22663
Bob Brown          78b8ffac-8bea-44a0-961a-62870b2c87
Diego Siciliani    4b1fda38-cc2e-42e9-afd1-18f1d18874
Grady Archie       ae0342e9-5cf9-416e-9fb7-154ec6eb27
Expected behavior

It's expected to get the number of items specified with the -Top parameter.

How to reproduce
# it returns 4 items, although 3 items are requested
PS> get-mguser -top 3 -PageSize 2

# returns 9 items although 7 items are requested
PS> get-mguser -top 7 -PageSize 3
SDK Version

2.20.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with Get-MgUser using -Top 3 -PageSize 2 and -Top 7 -PageSize 3, then trace the SDK's paging behavior for these parameters. Done means each command returns exactly the number of items requested by -Top, including when the values are not evenly divisible.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.