SonarCloud PR decoration not working (even after creating new token)

I’m using a SonarCloud trial to set up a PoC to demo pull request decoration to my fellow devs & management. I’ve been following the documentation of the SonarCloud VSTS lab (https://docs.microsoft.com/en-us/labs/devops/sonarcloudlab/index) and, while sonarcloud analyses my pull request branch and finds (expected) issues, these issues are not decorated in my PR as in the original post.

I’ve already tried creating a new token, but this doesn’t resolve the issue for me. What can I do to troubleshoot this connection?

Hi Joris,

can you give me the task ID of a PR that has been processed by SonarCloud but not decorated on VSTS side please? You can find this ID in the “Background Tasks” page of your projects:

Hi Fabrice,
Task ID of one of the PRs is AWTwgWT_8jHLMyTQVLD5

Thanks Joris.

I looked at the logs, and this confirms my feeling. There is a HTTP 401 Unauthorized error, which means there is an issue with the token you specified on your project:

2018.07.31 15:22:53 INFO  ce[AWTwgWT_8jHLMyTQVLD5][o.s.c.t.CeWorkerImpl] Execute task | project=interaction | type=REPORT | id=AWTwgWT_8jHLMyTQVLD5 | submitter=AWTvERTnGEjsfxbZAp0n
2018.07.31 15:22:56 WARN  ce[AWTwgWT_8jHLMyTQVLD5][c.s.b.p.v.VstsPrFacadeFactoryImpl] Failed to access VSTS, the repository or the Pull Request: API resource location xxxxxxx is not registered on https://xxxxxxxx.visualstudio.com/. HTTP 401 Unauthorized
2018.07.31 15:22:56 INFO  ce[AWTwgWT_8jHLMyTQVLD5][o.s.c.t.CeWorkerImpl] Executed task | project=interaction | type=REPORT | id=AWTwgWT_8jHLMyTQVLD5 | submitter=AWTvERTnGEjsfxbZAp0n | status=SUCCESS | time=3615ms

Note that we are planning to improve this situation so that you get this kind of warning right inside the web application and therefore you can act on this. See MMF-1244 for more details about this upcoming improvement.

Thanks for the information, Fabrice.

On a hunch I asked one of our VSTS admins to generate a token instead. Once I used that token, PRs were decorated with SonarCloud comments.

Seems that, even though I can manually add comments to the PR in question, my personal token is not enough for automated comments. Some internal VSTS permission could be a factor in blocking the decoration of the PR.

1 Like