SonarQube 9.3 GitLab MR decoration use wrong link to MR


I’m using SonarQube 9.3.0 developer edition deployed to Kubernetes as helm chart.

I noticed this error in logs when was investigating missing PR decaorations

2022.03.09 16:47:30 ERROR ce[AX9vlAhLxgO38IPcrG9r][o.s.a.c.g.GitlabHttpClient] Gitlab API call to [] failed with 404 http code. gitlab response content : [{"message":"404 Not found"}]
2022.03.09 16:47:30 ERROR ce[AX9vlAhLxgO38IPcrG9r][c.s.F.D.E.A] An exception was thrown during Merge Request decoration : GitLab Merge Request did not happen, please check your configuration

When I checked the GitLab API, it has no data returned under url in the error message, so I checked all MRs for that project. I found that MR, it has the same ID as in log message, 92304:

But the thing is, when calling GitLab API to get the MR you need to provide iid instead of id, according to GitLab docs: Merge requests API | GitLab

And when I changed ID to IID io the URL (9230440), it worked:

Hey there.

Are you using Gitlab CI for the build?

This can really only be messed up if the value for the CI_MERGE_REQUEST_IID environment variable in your build pipeline is somehow configured incorrectly. That’s the value that ultimately trickles back to SonarQube (as sonar.pullrequest.key) and is used for making API calls against GitLab.

:man_facepalming: Totally makes sense! I think documentation here should be more explicit then :slight_smile:

Running from GitLab CI usually means you don’t have to set anything related to Merge Request analysis. Can you help me understand more why you’re setting this up manually?