Skip to content

Commit a7f571e

Browse files
psturctamas-la
authored andcommitted
fix: sonarqube: missing api/users/search endpoint (#8813)
1 parent b46f10c commit a7f571e

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

backend/plugins/sonarqube/impl/impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func (p Sonarqube) PrepareTaskData(taskCtx plugin.TaskContext, options map[strin
136136
Options: op,
137137
ApiClient: apiClient,
138138
TaskStartTime: time.Now(),
139+
IsCloud: connection.IsCloud(),
139140
}
140141
// even we have project in _tool_sonaqube_projects, we still need to collect project to update LastAnalysisDate
141142
var apiProject *models.SonarqubeApiProject

backend/plugins/sonarqube/tasks/accounts_collector.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,20 @@ func CollectAccounts(taskCtx plugin.SubTaskContext) errors.Error {
3636
logger := taskCtx.GetLogger()
3737
logger.Info("collect accounts")
3838
rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_ACCOUNTS_TABLE)
39+
40+
// SonarCloud removed api/users/search - use organizations/search_members instead
41+
// The "organization" query param is auto-added by PrepareApiClient
42+
urlTemplate := "users/search"
43+
if data.IsCloud {
44+
urlTemplate = "organizations/search_members"
45+
logger.Info("using organizations/search_members for SonarCloud")
46+
}
47+
3948
collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
4049
RawDataSubTaskArgs: *rawDataSubTaskArgs,
4150
ApiClient: data.ApiClient,
4251
PageSize: 100,
43-
UrlTemplate: "users/search",
52+
UrlTemplate: urlTemplate,
4453
Query: func(reqData *helper.RequestData) (url.Values, errors.Error) {
4554
query := url.Values{}
4655
query.Set("p", fmt.Sprintf("%v", reqData.Pager.Page))

backend/plugins/sonarqube/tasks/task_data.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ type SonarqubeTaskData struct {
3737
ApiClient *api.ApiAsyncClient
3838
LastAnalysisDate *time.Time
3939
TaskStartTime time.Time
40+
IsCloud bool
4041
}
4142

4243
func DecodeAndValidateTaskOptions(options map[string]interface{}) (*SonarqubeOptions, errors.Error) {

0 commit comments

Comments
 (0)