fix(auth): read full page number from listUsers Link header#2465
Open
Lastrixxs wants to merge 2 commits into
Open
fix(auth): read full page number from listUsers Link header#2465Lastrixxs wants to merge 2 commits into
Lastrixxs wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔍 Description
Fixes a pagination bug in
GoTrueAdminApi.listUsers(). The page number from theLinkheader was parsed with.substring(0, 1), which truncates any multi-digit page to its first digit — sonextPage/lastPagebecome wrong once results pass page 9 (e.g.page=10→1). This reads the fullpagevalue instead.What changed?
The
Link-header page-number parse used.substring(0, 1), keeping only the first character. Replaced it with a match that reads the fullpagevalue. The same parse appears twice in the file (listUsersand the OAuth-clients lister); both are fixed.packages/core/auth-js/src/GoTrueAdminApi.ts:Why was this change needed?
listUsers()derivesdata.nextPage/data.lastPagefrom theLinkheader, but.substring(0, 1)truncates any multi-digit page number to its first digit:page=10→1,page=23→2. A caller looping onnextPagejumps backwards / loops once results pass page 9 — silently, with no error. At the defaultper_pageof 50 that is any project with more than ~450 users.Repro:
Behaviour for a single-page response (no
Linkheader) is unchanged.📸 Screenshots/Examples
LinkheadernextPagebeforepage=222page=101❌10✅page=232❌23✅🔄 Breaking changes
📋 Checklist
<type>(<scope>): <description>pnpm nx formatto ensure consistent code formatting📝 Additional notes
The identical parse exists in two methods in this file; both are fixed. The bug only affects the
nextPage/lastPagemetadata —data.usersis correct — so only consumers relying onnextPagepast page 9 are impacted.