Pull Requests on TeamCity result in empty code tab

We’re using SonarQube 8.8, the SonarScanner for MSBuild 5.2.1 and no specific extensions. We’re also using TeamCity as our build server and have configured all our builds to check out the GitHub repository on the agent.

After some digging, for the last couple of months we’ve been building the develop branch using the teamcity.git.fetchAllHeads setting to true to make sure all heads are available. However, for some reason, enabling this option for our PR builds results in an empty SQ report where everything is green and the Code tab is completely empty. The SQ log-file is completely fine and no warnings are reported. This is the (sanitized) command-line we use:

dotnet tool run dotnet-sonarscanner begin /k:Platform_OVS /n:"OVS" /v:3.7.1-alpha.0.12.build-2772 /d:sonar.pullrequest.provider=github /d:sonar.pullrequest.github.repository=SomeOrg/OVS /d:sonar.pullrequest.base=develop /d:sonar.pullrequest.branch=pull/646 /d:sonar.pullrequest.key=646 /d:sonar.sourceEncoding=UTF-8 /d:sonar.login=******* /d:sonar.host.url=https://sonarqube.dev.someorg.io /d:sonar.cs.vstest.reportsPaths=artifacts/OVS.Tests.xml /d:sonar.cs.opencover.reportsPaths=artifacts/coverage.opencover.xml

Setting teamcity.git.fetchAllHeads to false fixes this problem, but sometimes results in issues in files that were not even in the PR. It also reports warnings like:

WARN: Could not find ref '%s' in refs/heads, refs/remotes, refs/remotes/upstream or refs/remotes/origin
WARN: Missing blame information for the following files:

What’s also weird, that the build on develop, which is using the fetch-all-heads flag still reports:

WARN: Missing blame information for the following files:

Even though TeamCity reports

Forced fetch of all heads (teamcity.git.fetchAllHeads=true)

So I suspect that all these warnings are related, but with all our experience with SQ, we can’t figure out what’s the right set of ingredients we need to make it work reliably.