Skip to content

Bug: new pagination logic increments page index incorrectly #783

@pylipp

Description

@pylipp

Checklist

  • I have looked into the Readme and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

I'm using the new (v5.1.0) SDK and I want to iterate over my 108 roles.

Investigation

The pagination logic in the RawClient incorrectly increments the page index for the lambda function get_next:

page=page + len(_items or []),

When I change it to page=page + 1, it correctly works.

Other paginated queries, e.g. listing users, and in the AsyncClient, also suffer from this. I found more than 60 occurrences of the pattern page = page + len(items or []) in the code base.

Reproduction

client = ManagementClient(...)
resp = client.roles.list()
for i, role in enumerate(resp):
    print(f"{i}: {role.name}")

Expected output

108 lines with the role names

Actual input

50 lines with the role names (50 is the default for the per_page parameter)

Additional context

No response

auth0-python version

5.1.0

Python version

3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis points to a verified bug in the code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions