Importing GitLab projects fails to connect

We recently upgraded from Community Edition to Developer Edition Version 8.9.1 (build 44547). We have an ALM integration with hosted GitLab and it worked great when using the Community Edition. Not sure if it’s related to us upgrading to Developer Edition or not, but ever since, I cannot import projects from GitLab. When I click on import project and then GitLab, it spins for awhile and then shows this error: Could not get projects from GitLab instance. Using the browser dev tools, the response code is a 400 for the API /api/alm_integrations/check_pat?almSetting=gitlab and the response is: {"errors":[{"msg":"Could not get projects from GitLab instance"}]}. I have tried creating a new personal access token with the correct permissions in GitLab and updating Sonar to use that, but it has not helped.

Hi @jtkehoe ,

Welcome to SonarSource Community :sonarsource: !

Can you check what API URL you are using? It should be, not

If that doesn’t help, can you do the following?

  • Change your Log Level to DEBUG (Administration > System > Log Level) - no need to restart SonarQube
  • Attempt to import GitLab projects
  • Attach your access.log and web.log file

If you prefer to privately message me, then just let me know instead.


Thank you @Joe .

I checked the URL and it is correct (without the trailing slash).

I changed the logging to debug and found something interesting. The web.log has the following:

2021.06.28 20:10:29 ERROR web[AXo0h2Q0O9liaM5nACRz][o.s.a.c.g.GitlabHttpClient] Gitlab API call to [] failed with 500 http code. gitlab response content : [{"message":"500 Internal Server Error"}]
2021.06.28 20:10:29 DEBUG web[][o.i.c.TaskRunner] Q10008 starting              : OkHttp ConnectionPool
2021.06.28 20:10:29 DEBUG web[][o.i.c.TaskRunner] Q10008 run again after 300 s : OkHttp ConnectionPool
2021.06.28 20:10:29 DEBUG web[][o.i.c.TaskRunner] Q10008 finished run in 148 µs: OkHttp ConnectionPool

When I play with the URL, I also get a 500. Looking up the documentation for GitLab projects API, I do NOT see a parameter for per_page. When I take that out of the URL, it works fine for me locally and I do not get a 500. Is this a bug that I should log?

Thanks for your help,

1 Like

Hi @jtkehoe !

Thanks for checking and sharing the log. SonarQube uses GitLab API’s offset-based pagination, which describes usage of page and per_page. I’m not sure it’s a bug yet, but let me notify our SonarQube developers and we’ll double-check this.

1 Like

Hi @Joe ,

Maybe this is a GitLab bug. I think they just released a new version of hosted GitLab. But this is strange… when I set per_page=20 (the default), it works fine, but setting per_page to anything under 12 throws a 500 exception.


1 Like

Hi @jtkehoe ,

You were right! We have confirmed the issue you are seeing as a bug on GitLab API side, and actually we already had filed a bug request here: Internal Server Error 500 when a request with pagination size under 12 on (#334667) · Issues · / GitLab · GitLab


Thanks @Joe ! I’ll keep an eye on the GitLab bug request.

1 Like

Does anyone have a workaround until this gets fixed other than just adding the project manually?

FYI this bug has been fixed in 9.0.1 and in 8.9.2. version of SonarQube.
GitLab is in progress to fix the bug on its side so it should soon work again other versions of SonarQube :wink:

Christophe - DevOps Platform PM

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.