Infinite loop when using nextLink in GET /me/people response

Open
#1,656 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
node.js, typescript
Domain
api

Research direction

Start with the Node client entry point shown in the report, client.api('/me/people'), and reproduce the response using SDK version 3.0.7. Inspect whether the returned @odata.nextLink preserves the same results and skip=0; done means pagination advances or omits nextLink when no people remain.

Written by the indexing model from the issue text.

Description

Bug Report

Prerequisites

  • Can you reproduce the problem?
  • Are you running the latest version?
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

In my app, I'm using the people API to return a list of relevant people to the logged-in user. I'm then taking the nextLink in the API response to request the remaining people, but this results in an infinite loop. After taking a closer look, I noticed that the skip param value in the @odata.nextLink URL is 0, which I believe is the culprit.

Steps to Reproduce

For brevity, I'm including code to get the initial nextLink response, but I can include my looping logic if needed.

import { Client } from '@microsoft/microsoft-graph-client';

const client = Client.init({
    authProvider: (done) => done(null, 'ACCESS_TOKEN')
  });

let request = client.api('/me/people');

const properties = [
  'id',
  'displayName',
  'givenName',
  'surname',
  'scoredEmailAddresses',
  'phones'
];

request = request.select(properties);

const response = await request.get();
console.log(response['@odata.nextLink']);

The console should log https://graph.microsoft.com/v1.0/me/people?%24select=id%2cdisplayName%2cgivenName%2csurname%2cscoredEmailAddresses%2cphones&%24skip=0.

Expected behavior: The skip param in the @odata.nextLink URL should be offset by the number of returned results in order to request the following "page." If there are no more people to return, @odata.nextLink should be undefined.

Actual behavior: The @odata.nextLink URL in the response has a skip param of 0, thereby returning the same results in following requests and resulting in an infinite loop.

Usage Information

SDK Version - 3.0.7

  • Node (Check, if using Node version of SDK)

Node Version - 20.11.1

Dominant language
TypeScript
Stars
833
Forks
240
PR merge metrics
No merged PRs in 30d

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.

More from microsoftgraph/msgraph-sdk-javascript

All issues in microsoftgraph/msgraph-sdk-javascript

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.