Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
5 tasks done
shelbycotton opened this issue Mar 25, 2024 · 0 comments
Open
5 tasks done

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

shelbycotton opened this issue Mar 25, 2024 · 0 comments

Comments

@shelbycotton
Copy link

shelbycotton commented Mar 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant