File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
backend/plugins/gitlab/tasks Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ func init() {
3636}
3737
3838const RAW_USER_TABLE = "gitlab_api_users"
39+ const KEYSET_MIN_VERSION = "v16.5.0"
3940
4041var CollectAccountsMeta = plugin.SubTaskMeta {
4142 Name : "Collect Users" ,
@@ -62,6 +63,14 @@ func CollectAccounts(taskCtx plugin.SubTaskContext) errors.Error {
6263 urlTemplate = "/users"
6364 }
6465
66+ useKeyset := false
67+ if urlTemplate == "/users" && semver .IsValid (apiVersion ) && semver .Compare (data .ApiClient .GetData (models .GitlabApiClientData_ApiVersion ).(string ), KEYSET_MIN_VERSION )>= 0 {
68+ useKeyset = true
69+ } else if urlTemplate == "/users" && ! semver .IsValid (apiVersion ) {
70+ // If version unknown, be conservative for CE 11–16.4: default to offset
71+ logger .Debug ("GitLab version is unknown/invalid; falling back to offset pagination for /users" )
72+ }
73+
6574 var lastID int
6675
6776 collector , err := api .NewApiCollector (api.ApiCollectorArgs {
@@ -71,7 +80,8 @@ func CollectAccounts(taskCtx plugin.SubTaskContext) errors.Error {
7180 PageSize : 100 ,
7281 Query : func (reqData * api.RequestData ) (url.Values , errors.Error ) {
7382 query := url.Values {}
74- if urlTemplate == "/users" {
83+ // Use keyset only when gated true and only on /users endpoint
84+ if useKeyset && urlTemplate == "/users" {
7585 query .Set ("pagination" , "keyset" )
7686 query .Set ("order_by" , "id" )
7787 query .Set ("sort" , "asc" )
You can’t perform that action at this time.
0 commit comments