Skip to content

Comments

feat(gitlab): implemented keyset pagination for gitlab #8529#8572

Closed
moulivashisth wants to merge 9 commits intoapache:mainfrom
moulivashisth:feat-gitlab-pagination
Closed

feat(gitlab): implemented keyset pagination for gitlab #8529#8572
moulivashisth wants to merge 9 commits intoapache:mainfrom
moulivashisth:feat-gitlab-pagination

Conversation

@moulivashisth
Copy link

@moulivashisth moulivashisth commented Sep 12, 2025

⚠️ Pre Checklist

Please complete ALL items in this checklist, and remove before submitting

  • I have read through the Contributing Documentation.
  • I have added relevant tests.
  • I have added relevant documentation.
  • I will add labels to the PR, such as pr-type/bug-fix, pr-type/feature-development, etc.

Summary

Fix GitLab Users collection hitting offset pagination limits by adding keyset pagination.

This PR updates the GitLab CollectAccounts subtask to avoid max offset errors when collecting large user sets:

  • Self-managed GitLab instances now use keyset pagination on /api/v4/users
    (pagination=keyset&order_by=id&sort=asc&per_page=N&id_after=<last_id>) and do not send page.
  • gitlab.com / jihulab.com keep existing behavior on project member endpoints
    (/projects/:id/members[/all]) which typically remain under offset caps per project.
  • Retains existing API-version fallback (/members/all vs /members/ for < v13.11).
  • Response parser now tracks the last item’s id to advance the keyset cursor safely.
  • No breaking changes to task wiring or raw table schema (gitlab_api_users).

Why: Some instances enforce strict offset caps (e.g., 50k), causing offset pagination is restricted errors when fetching Users. Keyset pagination removes the offset and enables full retrieval.

Risk/Compatibility:

  • Backward compatible; only changes query parameters and cursor handling.
  • If a project’s members list exceeds offset caps and the endpoint lacks keyset, users should collect site users (self-managed path) or shard by project/group—unchanged from current guidance.

Does this close any open issues?

Closes 8529 ([Bug][GitLab] Pagination not working Again)

Screenshots

N/A

Other Information

Signed-off-by: VASHISTH Chandramouli <c.vashisth@soprasteria.com>
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux labels Sep 12, 2025
@klesh
Copy link
Contributor

klesh commented Sep 17, 2025

Is keyset and api/v4 available in Community Edition 11+ ?

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Sep 18, 2025
@moulivashisth
Copy link
Author

Thanks for bringing this up!
• Keyset pagination for /api/v4/users was introduced in 16.5, and 17.0+ requires it for large responses.

I’ve updated the code to gate keyset by server version (≥16.5) and fallback to offset otherwise. Project members endpoints keep their existing offset behavior.

This preserves compatibility with CE 11–16.4 while avoiding offset-cap failures on newer instances.

klesh
klesh previously approved these changes Sep 22, 2025
Copy link
Contributor

@klesh klesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for your contribution.

@moulivashisth
Copy link
Author

Thanks for the review.

I hit a typecheck error:
plugins/gitlab/tasks/account_collector.go:69:55: undefined: apiVersion

Fix: Declared and reused a single apiVersion variable sourced from the client.

@klesh
Copy link
Contributor

klesh commented Sep 24, 2025

Hi, you may run the following command to fix the golangci-lint error:

gofmt -s -w -l plugins/gitlab/tasks/account_collector.go

@moulivashisth moulivashisth changed the title implemented keyset pagination for gitlab #8529 feat(gitlab): implemented keyset pagination for gitlab #8529 Oct 3, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

This pull request has been automatically marked as stale because it has not had recent activity for 120 days. It will be closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the Stale label Feb 1, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2026

This pull request has been closed because it has not had recent activity. You could reopen it if you try to continue your work, and anyone who are interested in it are encouraged to continue work on this pull request.

@github-actions github-actions bot closed this Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/plugins This issue or PR relates to plugins pr-type/bug-fix This PR fixes a bug severity/p1 This bug affects functionality or significantly affect ux size:M This PR changes 30-99 lines, ignoring generated files. Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants